when i use linearlayout everything works like its supposed except my button is at the top and not the bottom of the screen.
when i use relativelayout my button is on the bottom like its supposed to but only works for the first listview entry after that it stops working…
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<Button android:id="@+id/plus"
android:background="@drawable/selector"
android:layout_width="fill_parent"
android:layout_height="75dp"
android:layout_alignParentBottom="true"
/>
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
</ListView>
<TextView android:id="@android:id/empty" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="@string/helptxt1"
/>
</RelativeLayout>
..
public void addListenerOnButton() {
final Context context = this;
button1 = (Button) findViewById(R.id.plus);
button1.setOnClickListener(new OnClickListener() {
// @Override
public void onClick(View arg0) {
createNote();
// Intent intent = new Intent(context, QuoteEdit.class);
// startActivity(intent);
}
});
}
private void createNote() {
Intent i = new Intent(this, QuoteEdit.class);
startActivityForResult(i, ACTIVITY_CREATE);
}
Your buttons wont work because when you use a Relative layout all the views/buttons are placed in the same location unless you place them above or below each other. Try doing this with your layout:
or you can add an onClick to your button:
and in your code