我正在开发 android 应用程序和应用程序,其操作栏包含刷新按钮和溢出菜单,操作栏下方有两个堆叠选项卡。当我单击刷新按钮时,将为该任务刷新单个选项卡,我想使用意图从外部类调用内部类,以便我可以从服务器刷新内部类。
当我尝试使用意图从外部类调用内部类时,我遇到了 ActivityNotfound 异常之类的异常,但在解决后我已经在清单中提到了内部类。我尝试了很多方法,但没有奏效。
以下是我的班级结构
public class Fragment extends SherlockFragmentActivity {
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
Tab tab = actionBar.newTab().
setText("Tab1").
setTabListener(new Tab1())
;
actionBar.addTab(tab);
tab = actionBar.newTab().
setText("Tab2").
setTabListener(new Tab2())
;
actionBar.addTab(tab);
//I am tried number ways to refesh the particlar tab but not achieve my goal
public void Refresh() {
/* I am also write Refresh method on individual tab and call from
onOptionsItemSelected but not working*/
Intent href = new Intent(Fragment.this,
Tab1.class);
startActivity(href);
finish();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_refresh:
Refresh();
return true;
default:
break;
}
}
//inner class for tab first
public class Tab1 extends SherlockListFragment implements ActionBar.TabListener{
// here implementating the TabListener method
//here I am loading the list from server
private class LoadProjects extends AsyncTask<String, String, String> {
//call webservice
}
}
// inner class for tab second
public class Tab2 extends SherlockListFragment implements ActionBar.TabListener{
// here implementating the TabListener method
//here I am loading the list from server
private class LoadProjects extends AsyncTask<String, String, String> {
//call webservice
}
}
}
androidmanifest.xml
<application>
<activity
android:name="com.ojaswitech.bookingscape.Fragment"
android:configChanges="orientation|keyboardHidden"
android:label=""
android:logo="@drawable/action_bar_logo"
android:theme="@style/Theme.New_theme_bs" >
</activity>
<activity
android:name="com.ojaswitech.bookingscape.Fragment$Tab1"
android:configChanges="orientation|keyboardHidden" >
</activity>
<activity
android:name="com.ojaswitech.bookingscape.Fragment$Tab2"
android:configChanges="orientation|keyboardHidden" />
</application>
请任何人帮助我如何完成上述任务。提前致谢