Click a TextView in a ListView to open another layout page

I am trying to enable a textview on my listview clickable and then open another layout:

  private class IndexListAdapter extends ArrayAdapter<Index>{
        public IndexListAdapter(){
            super(MainActivity.this, R.layout.listview_item, index);

        public View getView(int position, View view, ViewGroup parent){
            if (view == null)
                view = getLayoutInflater().inflate(R.layout.listview_item, parent, false);

            Index currentIndex = index.get(position);

            TextView name = (TextView) view.findViewById(;

            name.setOnClickListener(new View.OnClickListener() {

                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    items.add(new Item(patientTxt.getText().toString(), operatorTxt.getText().toString(),
                            serialTxt.getText().toString(), deviceTxt.getText().toString(), dateTxt.getText().toString(),
                            assetTxt.getText().toString(), locationTxt.getText().toString(), qcTxt.getText().toString()));
                    Intent intent = new Intent(MainActivity.this, Item.class);

            return view;

what i am trying to do is that I will have one item which is a name to show on a listview_item or a list tab and when I click on the name it will open up another layout or page to display another list of items.


You cannot call like this in your custom adapter so you will try like this it will work

 Intent intent = new Intent(MainActivity.this, Item.class);

You will change into this. You just send the context and using that one call the intent

 Intent i = new Intent(mContext, TabActivityPacs.class);
            i.putExtra("STUDY", study);

If you not able to get click event of TextView

add this attribute for your TextView


also add


for your ListView

Need Your Help

Symfony2 Accessing route variables

php symfony routing

I know I can access current route name by $request-&gt;get('_route');.

C++ repeated indirect vs direct access

c++ performance game-engine

This is a rather pedantic question, but I want to get the most performance out of my game. This game includes accessing an array of a data structure, but I dont know the size of this array (e.g. pl...