My goal is to make a ListView of each row of which contains one single button which occupies the entire space in each row. Below is the code where the onItemClick method does not work.Does anyone have idea why it does not work?
I have next class Activity:
public class MyActivity extends Activity implements OnItemClickListener {
public void onCreate(Bundle savedInstanceState) {
//
//Here is a lot of code..
//.....
List<String> items = new ArrayList<String>();
ListView lv = (ListView) findViewById(R.id.listView);
if (result.getItems().size() > 0) {
// Init list view
lv.setVisibility(lv.VISIBLE);
lv.setTextFilterEnabled(true);
lv.setAdapter(new buttonAdapter(this, R.layout.list_item,
items));
lv.setOnItemClickListener(this);
}
}
public void onItemClick(AdapterView<?> parent, View view, int position,long id) {
//....
}
}
And here is my XML-element for each row in the ListView:
<Button xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/list_item_button"
android:layout_gravity="center_vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
android:textStyle="bold"
android:textSize="16sp">
</Button>