1

As am getting article title on textview on first activity.how can i pass these textview to next activity...

I have used below code:

    for ( j = 0; j <Appscontent.Sub_arraylisttwo.size(); j++) 
      {
         LinearLayout ly = new LinearLayout(this);
         ly.setOrientation(LinearLayout.VERTICAL);
            ly.setOnClickListener(mArticleClick);
         TextView tv = new TextView(this);
         tv.setText(Appscontent.Sub_arraylisttwo.get(j));   

        ly.addView(tv);
        lLayout.addView(ly);
     }

       int num=Integer.parseInt(number);
       number=String.valueOf(num=num+1);
        System.out.println("the Number Value Is"+number);
          Appscontent.Sub_arraylisttwo.clear();

       hSroll.addView(lLayout);
       viewLayout.addView(headerText);
      viewLayout.addView(hSroll);
       verticalLayout.addView(viewLayout);

      Log.i("12", "" + lLayout.getChildCount());}
         }
      private OnClickListener   mArticleClick   = new OnClickListener() {

                                @Override
                                public void onClick(View v) {

                                Intent in = new Intent(MainActivity.this, SubCate.class);

                               startActivity(in); 

                                }
                            };

Here i have to click one article means that article name only pass to next activity and display that article title.. how can i do ??? please give me solution for these ???

user2098063
  • 85
  • 1
  • 1
  • 7

3 Answers3

2

if you want to use intents:

while going to the ListActivity pass data by..

intent.putExtra("Title", yourstring);
intent.putExtra("Content", yourstring);
startActivity(intent);

and to recover it in second activity use:

title= getIntent().getExtras().getString("Title");

...and so on..

X-Factor
  • 2,067
  • 14
  • 18
  • 2
    This is pretty much the answer. You can also create a Bundle object, and attach that to the Intent. – Knossos Mar 02 '13 at 09:59
1
//to pass :
 Intent in = new Intent(MainActivity.this, SubCate.class);
in.putExtra("name", "Artical Name");  
 startActivity(in);


// to retrieve object in second Activity
getIntent().getSerializableExtra("name");
duggu
  • 37,851
  • 12
  • 116
  • 113
0
 public void onClick(View view)
 {
    public void run()
    {
            Intent i=new Intent(activity1.this,activity2.class);
            i.putExtra("somename", variable1);
            i.putExtra("somename1", variable2);         

    }
 }

In the second activity

     Bundle extras = getIntent().getExtras();
    if (extras != null) {
        one= extras.getDouble("somename");
        two = extras.getDouble("somename2");

    }
Danny
  • 1,050
  • 3
  • 11
  • 26