0

I've created a button on the mainActivity. Once clicked, it takes a user to a second view. For some reason, there's no button to be seen anywhere and there's no errors? I have defined the layout in the xml.file and referenced it in the java.file. It's just strange that there's no obvious syntax errors and there's no button to be seen anywhere.

Below is the segment of the java code:

public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.reminder_list); mDbHelper = new RemindersDbAdapter(this); mDbHelper.open(); fillData(); registerForContextMenu(getListView()); setContentView(R.layout.reminder_list); final Button button = (Button) findViewById(R.id.insertion); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Performs action on click createReminder(); } }); 

}

This is the .xml file

http://imageshack.us/photo/my-images/171/xml.png/

Does anyone have any ideas?

Many thanks.

5
  • Can you show the Layout-XML you're using? Commented May 16, 2011 at 13:40
  • you should post the layout xml Commented May 16, 2011 at 13:40
  • can you post your layout file and complete java files.. Commented May 16, 2011 at 13:44
  • <Button android:id="@+id/insertion" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:text="@string/add_reminder" /> </LinearLayout> Commented May 16, 2011 at 13:55
  • This is the full .xml file imageshack.us/photo/my-images/171/xml.png Commented May 16, 2011 at 14:04

1 Answer 1

1

The problem is inside your layout.

You set the ListView with android:layout_height="fill_parent" so that listView will consume all the layout height and your button will not appear.

Try using wrap_content or using RelativeLayout if you need the button at the bottom of your Activity.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.