0

I have two class first is PageOne and Second is PageTwo, PageOne has list of content and on click on content, that content pass to PageTwo Class.

PageOne Class Using this code to track click contents

public void onItemClick(AdapterView parent, View view, int position, long id) {

        String s = (lv.getItemAtPosition(position).toString());

        Intent i=new Intent(PageOne.this, PageTwo.class);
        i.putExtra("name", s);
        startActivity(i);



    }

and PageTwo class can catch that content using this code

TextView Textv = (TextView) findViewById(R.id.singleidview);
Intent iin = getIntent();
Bundle b = iin.getExtras();
if (b != null) {
    String j = (String) b.get("name");
    Textv.setText(j);
}

when this String j output is:

{description=description about selected, title=selected title}

I searching a way for display description on one TextView and title in another TextView. How to do this, I can do this using split function. But I am searching a better way than using split.

Thank you...

user2757460
  • 11
  • 2
  • 5

1 Answers1

2

Try this way

Intent iin = getIntent();
Bundle b = iin.getExtras();
if (b != null) {
    String j = (String) b.get("name");
    JSONObject name = new JSONObject(j);

    Textv.setText(name.getString("title"));
    TextvDesc.setText(name.getString("description"));
}
Biraj Zalavadia
  • 28,348
  • 10
  • 61
  • 77