I am developing one application and in which i have to display a five tabs and on each tab i am calling a different activity.And in my last tab i displaying menus.
The main problem is that my activities are called only on tab changed events.when i am clicking on last tab first time it displays a menu and after selecting any menu if i click on that tab again then nothing happens.
So how to solve this kind of problem? is there any other way to do this task?
Any help will be appreciated.Thanks
Here is my code:
public class More extends ActivityGroup{
Button btn1;
ExpandableListView elw;
Context ctx;
public ListView modeList;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ctx=this;
Toast.makeText(More.this,"in more",200).show();
setContentView(R.layout.more);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("More Option");
modeList = new ListView(this);
String[] stringArray = new String[] { "About", "Settings","Invite By Message","Privacy Policy","Deactivate Account","Exit" };
ArrayAdapter<String> modeAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, stringArray);
modeList.setAdapter(modeAdapter);
builder.setView(modeList);
final Dialog dialog = builder.create();
dialog.show();
modeList.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
// TODO Auto-generated method stub
String item=(String) modeList.getItemAtPosition(position);
Toast.makeText(More.this,item,200).show();
switch(position) {
case 0:
setContentView(R.layout.about);
dialog.dismiss();
TabHost tabHost = welcome.self.getTabHost();
tabHost.setCurrentTab(4);
// tabHost.setCurrentTab(4);
break;
case 1:
setContentView(R.layout.settings);
dialog.dismiss();
break;
case 2:
setContentView(R.layout.messages);
dialog.dismiss();
break;
case 3:
setContentView(R.layout.policy);
dialog.dismiss();
break;
case 4:
Toast.makeText(More.this,"Deactivate the Account",200).show();
dialog.dismiss();
break;
default:
Toast.makeText(More.this,"Exit the application",200).show();
dialog.dismiss();
welcome.self.finish();
}
}
});
Now your NewClass.java
here are 4 tabs you can use as many as you want.
Register in android manifest.
Make sure your tabhost in layout file has the id same as in your code.
click right if you accept my answer.