I have created a Custom listView where i put some text and image but when i clicked in list view their is no response.I have created a custom Listview. if any one known then please tell me. my code is here
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final List<pdf> pdfList;
//the listview
final ListView listView;
//initializing objects
pdfList = new ArrayList<>();
listView = (ListView) findViewById(R.id.list);
//adding some values to our list
pdfList.add(new pdf("Book1", "First Year"));
pdfList.add(new pdf( "Book2", "First Year"));
//creating the adapter
ListAdptot adapter = new ListAdptot(this, R.layout.customlistview, pdfList);
//attaching adapter to the listview
listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick (AdapterView < ? > adapter, View view, int position, long arg){
if(position==0)
{
Toast.makeText(MainActivity.this, "Position 0", Toast.LENGTH_SHORT).show();
}
else if(position==1)
{
Toast.makeText(MainActivity.this, "Position 1", Toast.LENGTH_SHORT).show();
}
}
}
);
}
}