0

Android activities A which is a list activity , B is a detail information about list item

A is calling B and send data Id and Category

ListView lv = getListView();


    lv.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) {
            // getting values from selected ListItem


            String newsid = ((TextView) view.findViewById(R.id.idTV))
                    .getText().toString();

            Bundle bndl=new Bundle();

            bndl.putString("id", newsid);
            bndl.putString("cat", "sport");
            bndl.putString("prev", "SPORTPANEL");
            Intent in = new Intent("com.contact.lebadagency.SINGLECONTACTACTIVITY");
            //in.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            //in.putExtra("id", newsid);
            //in.putExtra("cat", "sport");
            in.putExtras(bndl);

            startActivity(in);


        }
    });

and the second Activity B :

Intent in=new Intent();
    in=getIntent();
    Bundle bundle = this.getIntent().getExtras(); 
    String news = bundle.getString("id").toString();
    String cat = bundle.getString("cat").toString();

When i install and run the application i click on any item on A activity and the correct data shown , the problem is that first selected data is stuck in Activity B , Stuck forever on the Activity B, i click on other items in list A and the old (first selected item) is stuck.

I hope i describe my problem well, any help ?

xyzdev
  • 23
  • 7

2 Answers2

0

I think your listview Is not properly formed. kindly go-through the below link for how to load it and how to pass to next activity.

below Links Will help you:

How can I set onClickListener on ArrayAdapter?

http://www.vogella.com/tutorials/AndroidListView/article.html

Community
  • 1
  • 1
Sivakumar
  • 633
  • 4
  • 9
0

I solve it , my main problem was kinda funny its two mistakes i need to fix and the crazy thing is that two mistakes coz the same error , i applied onNewIntent() in B activities and the other problem was using a static variable like this :

private static final ID ="row_id";
private static final TITLE ="row_t";

i use this variables to fetch id and title from json array and then before i set the result to the text view i change these variables values , and that cosed the next call of this activity to fail retrieve data from json object

just made a new variables

private static final ID ="set_id";
private static final TITLE ="set_t";

and used them , and keep ID and TITLE unchanged.

I know this might be a useless information but had to share it might help someone

xyzdev
  • 23
  • 7