ive seen a post before and i tried to copy and implement it on my porject but i have trouble doing so this is the link that im talking about How do I create a header or footer button bar for my Android application it is on implementing header and footer my problem is that i cant put on my activity in the middle how can i do it in all my activity here is the code for my activity main activity import android.os.Bundle;
@SuppressWarnings("deprecation")
public class ShareAnews extends TabActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_shareanews);
TabHost tabhost = (TabHost) findViewById(android.R.id.tabhost);
TabSpec Tab1 = tabhost.newTabSpec("tab1");
TabSpec Tab2 = tabhost.newTabSpec("tab2");
TabSpec Tab3 = tabhost.newTabSpec("tab3");
TabSpec Tab4 = tabhost.newTabSpec("tab4");
Tab1.setIndicator("Traffic").setContent(new Intent(this,ShareAnewsTraffic.class));
Tab2.setIndicator("Accident").setContent(new Intent(this,ShareAnewsAccident.class));
Tab3.setIndicator("Hazard").setContent(new Intent(this,ShareAnewsHazard.class));
Tab4.setIndicator("Crime").setContent(new Intent(this,ShareAnewsCrime.class));
tabhost.addTab(Tab1);
tabhost.addTab(Tab2);
tabhost.addTab(Tab3);
tabhost.addTab(Tab4);
}
}
1st activity
import android.app.Activity;
public class ShareAnewsHazard extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_shareanewshazard);
}
}
2nd activity
import android.app.Activity;
public class ShareAnewsTraffic extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_shareanewstraffic);
}
}
3rd activity
import android.app.Activity;
public class ShareAnewsAccident extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_shareanewsaccident);
}
}
4th activity
import android.app.Activity;
public class ShareAnewsCrime extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_shareanewscrime);
}
}
.
stackoverflow.comm
No comments:
Post a Comment