Reputation: 501
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.
Upvotes: 0
Views: 112
Reputation: 27613
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.
Upvotes: 1