private View getChapterLayout() {
ListView listView = new ListView(this);
listView.setAdapter(new BaseAdapter() {
public int getCount() {
return chapterdata.size();
}
public Object getItem(int position) {
return chapterdata.get(position);
}
public long getItemId(int addressList) {
return 0;
}
public View getView(int position, View convertView,
ViewGroup parent) {
inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.button_chapter, null);
TextView textview = (TextView) convertView
.findViewById(R.id.button);
textview.setText(chapterdata.get(position).getName());
return convertView;
}
});
return listView;
}
// chapterdata is an arrayList
// Add Event to each Row
listView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
final int position, long id) {
try {
runOnUiThread(new Runnable() {
@Override
public void run() {
}
});
} catch (Exception e) {
// TODO: handle exception
}
}
});
No comments:
Post a Comment