Android 选项卡活动不适用于startActivityforResult()
我有一个NewMessage活动,我从中调用Tab活动。选项卡活动包含3个选项卡联系人|组|所选联系人我将在“联系人”选项卡上选择一些联系人,并将这些联系人重新定向到NewMessage。这东西在没有选项卡活动的情况下运行良好 我指的是一些链接 我的代码: 调用选项卡活动 选项卡类 这是Tab1.Class,我需要从中传递值ActionBar保存按钮单击 我在Tab.Class中有declare action\u bar save按钮,因为如果我在Tab1.Class中声明它,它不会显示。这是我在单击save按钮时返回的代码Android 选项卡活动不适用于startActivityforResult(),android,tabactivity,onactivityresult,Android,Tabactivity,Onactivityresult,我有一个NewMessage活动,我从中调用Tab活动。选项卡活动包含3个选项卡联系人|组|所选联系人我将在“联系人”选项卡上选择一些联系人,并将这些联系人重新定向到NewMessage。这东西在没有选项卡活动的情况下运行良好 我指的是一些链接 我的代码: 调用选项卡活动 选项卡类 这是Tab1.Class,我需要从中传递值ActionBar保存按钮单击 我在Tab.Class中有declare action\u bar save按钮,因为如果我在Tab1.Class中声明它,它不会显示。这是我
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
//Save Button Click
if (id == R.id.action_done)
{
for(int i = 0; i < ViewContactName.size(); i++)
{
if(ma.mCheckStates.get(i)==true)
{
SelectedName.add(ViewContactName.get(i));
SelectedPhoneNumber.add(ViewContatcPhnoeNo.get(i).replaceAll("[^0-9,+]", ""));
}
}
Intent intent = new Intent();
intent.putStringArrayListExtra("ContactName",(ArrayList<String>) SelectedName);
intent.putStringArrayListExtra("ContactNumber", (ArrayList<String>) SelectedPhoneNumber);
setResult(RESULT_OK, intent);
finish();
}
return super.onOptionsItemSelected(item);
}
那么解决办法是什么呢?我使用了TabHost你应该提供相关的代码。@马库斯:我现在已经把所有与我的问题有关的代码都放在这里了
public class Tab extends TabActivity {
/** Called when the activity is first created. */
@SuppressLint("NewApi")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tab);
android.app.ActionBar actionBar = getActionBar();
actionBar.setHomeButtonEnabled(false);
actionBar.setDisplayHomeAsUpEnabled(false);
TabHost tabHost = getTabHost();
// Tab for Photos
TabSpec PhoneBook = tabHost.newTabSpec("PhoneBook");
PhoneBook.setIndicator("PhoneBook");
Intent PhoneBook = new Intent(this, Tab1.class);
PhoneBook.setContent(photosIntent);
// Tab for Songs
TabSpec Groups = tabHost.newTabSpec("Groups");
// setting Title and Icon for the Tab
Groups.setIndicator("Groups");
Intent Groups = new Intent(this, Tab2.class);
Groups.setContent(Groups);
// Tab for Videos
TabSpec SelectedContacts = tabHost.newTabSpec("Selected Contacts");
SelectedContacts.setIndicator("Selected Contacts");
Intent SelectedContacts = new Intent(this, Tab3.class);
SelectedContacts.setContent(videosIntent);
// Adding all TabSpec to TabHost
tabHost.addTab(PhoneBook); // Adding PhoneBook
tabHost.addTab(Groups); // Adding Group PhoneBook
tabHost.addTab(SelectedContacts); // Adding SelectedContacts
}
//Menu Bar
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.contact_list, menu);
return super.onCreateOptionsMenu(menu);//This is actionBar Save Button
}
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
//Save Button Click
if (id == R.id.action_done)
{
Log.d("Activity","Tab");
}
return super.onOptionsItemSelected(item);
}
}
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
//Save Button Click
if (id == R.id.action_done)
{
for(int i = 0; i < ViewContactName.size(); i++)
{
if(ma.mCheckStates.get(i)==true)
{
SelectedName.add(ViewContactName.get(i));
SelectedPhoneNumber.add(ViewContatcPhnoeNo.get(i).replaceAll("[^0-9,+]", ""));
}
}
Intent intent = new Intent();
intent.putStringArrayListExtra("ContactName",(ArrayList<String>) SelectedName);
intent.putStringArrayListExtra("ContactNumber", (ArrayList<String>) SelectedPhoneNumber);
setResult(RESULT_OK, intent);
finish();
}
return super.onOptionsItemSelected(item);
}