4 개의 액티비티가 있습니다.TAB로 값 이전 액티비티
제 활성을 입력 데이터로 사용하고, 두번째 작업은 각 탭 활동을 선언 탭 주요 활동 (TabActivity 확장)이고, 3, 4 활동 탭 활동이다.
는어떻게 세 번째와 네 번째 활동에 첫 번째 활동에서 값을 전송할 수 있습니다 ?
여기 내 첫번째 활동이다 :
public class FirstActivity extends Activity {
EditText inputName;
EditText inputAddress;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//declaration layout
inputName = (EditText) findViewById(R.id.editText1);
inputAddress = (EditText) findViewById(R.id.editText2);
Button btnNextScreen = (Button) findViewById(R.id.button1);
//Listening to button event
btnNextScreen.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
//Starting a new Intent
Intent nextScreen = new Intent(getApplicationContext(), MainTabActivity.class);
//Sending data to another Activity
//THIS IS THE VALUE I WANNA TRANSFER TO TAB ACTIVITY
nextScreen.putExtra("name", inputName.getText().toString());
nextScreen.putExtra("address", inputEmail.getText().toString());
// starting new activity
startActivity(nextScreen);
}
});
}
}
여기 내 MainTabActivity입니다 :
public class MainTabActivity extends TabActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.maintabresto);
Resources res = getResources(); // Resource object to get Drawables
TabHost tabHost = getTabHost(); // The activity TabHost
TabHost.TabSpec spec; // Resusable TabSpec for each tab
Intent intent; // Reusable Intent for each tab
// Create an Intent to launch an Activity for the tab (to be reused)
intent = new Intent().setClass(this, InfoTab.class);
// Initialize a TabSpec for each tab and add it to the TabHost
spec = tabHost.newTabSpec("info").setIndicator("Info",
res.getDrawable(R.drawable.iconinfotab))
.setContent(intent);
tabHost.addTab(spec);
// Do the same for the other tabs
intent = new Intent().setClass(this, MenuTab.class);
spec = tabHost.newTabSpec("menu").setIndicator("Menu",
res.getDrawable(R.drawable.iconmenutab))
.setContent(intent);
tabHost.addTab(spec);
tabHost.setCurrentTab(2);
}
}
여기 내 3 4 활동이다 (나는 각 활동에 텍스트 뷰하기 전에 이전 값을 표시 싶어) :
public class InfoTab extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.infotab);
TextView txtname = (TextView) findViewById(R.id.textTEST1);
TextView txtaddress = (TextView) findViewById(R.id.TextTEST2);
//displaying data from previous activity
//this is didnt work
Intent i = getIntent();
// Receiving the Data
String name = i.getStringExtra("name");
String address = i.getStringExtra("address");
// Displaying Received data
//this is didnt work
txtname.setText(name);
txtaddress.setText(address);
}
}
누구든지 나를 도울 수 있습니까 ?? 내가 firts 활동에이 작업을 수행하려고했습니다!
Intent nextScreen = new Intent(getApplicationContext(), InfoTab.class);
작동 (값이 nextactivity에 옮겨진 대신 탭에서 활동을 개방 할 수있다, 활동 개방 개별적으로 (안 탭) .. .
그래서 여기 내 목표는 각 탭 활동에 가치를 전달하는 것입니다 그들은 MainTabActivity 아래 개방하고 있습니다.
죄송합니다, 좀 작은 실수에 있다고 생각하면 내 영어 밤은 좋아.
누구든지 나를 도울 수 있습니까 ?? –
해결 되었습니까? 나는 또한 문제에 직면하고있다. –