这是我的第二个活动,其中包含一般代码
package com.go.experimentfive;
import android.app.Activity;
import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TabHost;
public class SecondActivity extends TabActivity {
private TabHost mTabHost;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
mTabHost = getTabHost();
TabHost.TabSpec spec;
Intent intent;
// Greek Tab
intent = new Intent(this, GreekActivity.class);
spec = mTabHost.newTabSpec("Greek")
.setIndicator("Greek")
.setContent(intent);
mTabHost.addTab(spec);
// Norse tab
intent = new Intent(this, NorseActivity.class);
spec = mTabHost.newTabSpec("Norse")
.setIndicator("Norse")
.setContent(intent);
mTabHost.addTab(spec);
// Roman Tab
intent = new Intent(this, RomanActivity.class);
spec = mTabHost.newTabSpec("Roman")
.setIndicator("Roman")
.setContent(intent);
mTabHost.addTab(spec);
mTabHost.setCurrentTab(0);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.second, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
我的标签(挪威语)
package com.go.experimentfive;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class NorseActivity extends Activity{
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
TextView textView = new TextView(this);
textView.setText("Norse Mythology");
setContentView(textView);
}
}
(罗马)
package com.go.experimentfive;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class RomanActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
TextView textView = new TextView(this);
textView.setText("Roman Mythology");
setContentView(textView);
}
}
(希腊)
package com.go.experimentfive;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class GreekActivity extends Activity{
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
TextView textView = new TextView(this);
textView.setText("Greek Mythology");
setContentView(textView);
}
}
你建议我应该怎么做?我想在每个标签上插入大量单词和图像按钮。谢谢你的帮助