0

我想从这个活动中发送价值

public class HomeActivity extends android.app.TabActivity
{
    String uid;
protected void onCreate(Bundle savedInstanceState) 
      {
     super.onCreate(savedInstanceState);
     setContentView(R.layout.activity_home);
     TabHost tabHost = getTabHost();
     Intent intent = getIntent();
     uid = intent.getStringExtra("uid");  
     // Tab for ActivityOne
     TabSpec photospec = tabHost.newTabSpec("Home");
     photospec.setIndicator("Home", getResources().getDrawable(R.drawable.one));
     Intent photosIntent = new Intent(this, TabhomeActivity.class);
     photosIntent.putExtra("uid", uid);
     // startActivityForResult(photosIntent,0);
     photospec.setContent(photosIntent);

     // Tab for ActivitySecond
     TabSpec songspec = tabHost.newTabSpec("Today's Meeting");
     // setting Title and Icon for the Tab
     songspec.setIndicator("Today's Meeting",
                                          getResources().getDrawable(R.drawable.one));
     Intent songsIntent = new Intent(this,TodaysmeetingActivity.class);
     songspec.setContent(songsIntent);
     // Adding all TabSpec to TabHost
     tabHost.addTab(photospec); // Adding photos tab
     tabHost.addTab(songspec); // Adding songs tab  
    }
 }

到这个活动..

public class TabhomeActivity extends Activity {

Button button1;
Button button2;
Button button3;
TextView txtview,shwname;
String uid;

@Override
public void onCreate(Bundle savedInstanceState) 
{ 

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tabhome);
    Intent intent = getParent().getIntent();
    uid = intent.getStringExtra("uid");
    shwname=(TextView)findViewById(R.id.textView3);
    shwname.setText("Hi\t"+uid);
 }

谁能帮我??请。提前致谢。

4

2 回答 2

0

试试下面的。

Intent intent = getIntent();
Bundle extras = intent.getExtras();
uid = getIntent().getExtras().getString(YOUR_KEY);  

同样,将您的数据设置为意图使用时

extras.putString(YOUR_KEY, YOUR_VALUE);
于 2013-04-26T09:43:14.293 回答
0

发送时:

Intent i = new Intent();
intent.putString("uid", uid);

收到时:

Intent intent = getIntent();
Bundle extras = intent.getExtras();
uid = getIntent().getExtras().getString("uid");  

或(使用捆绑包):

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    savedInstanceState = getIntent().getExtras();
    uid = savedInstanceState.getString("uid");
}
于 2013-04-26T10:21:01.807 回答