I am working in an Android app where I need to create onItemClick
method,but I fail to do so. Below is the code where the onItemClick
method does not work. Does anyone have idea why it does not work?
public class sample extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.live_chat_screen);
mListview = (ListView) findViewById(R.id.mLiveview);
mListview.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapters, View childView,int position, long arg3) {
// TODO Auto-generated method stub
Toast.makeText(sample.this,"Item number : " + position + " clicked",Toast.LENGTH_LONG).show();
}
});
here is the xml:
<ListView
android:id="@+id/mLiveview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fastScrollEnabled="true"
android:scrollbars="vertical" >
</ListView>
Actually I have used two views in my app first is when the app is open and the another view is open while the listview is getting load.
Could somebody help me out.