Ввёл следующее в MainActivity.java:
public class MainActivity extends ActionBarActivity implements View.OnClickListener {
Button btnActTwo;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ListView lvMain = (ListView) findViewById(R.id.lvMain);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, names);
lvMain.setAdapter(adapter);
btnActTwo = (Button) findViewById(R.id.btnActTwo);
btnActTwo.setOnClickListener(this);
}
public void onClick(View v) {
switch (v.getId()) {
case R.id.btnActTwo:
Intent intent = new Intent(this, ActivityTwo.class);
startActivity(intent);
// TODO Call second activity
break;
default:
break;
}
}
}
public class MainActivity extends Activity implements ActionBar.TabListener {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ActionBar bar = getActionBar();
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
ActionBar.Tab tab = bar.newTab();
tab.setText("Tab1");
tab.setTabListener(this);
bar.addTab(tab);
tab = bar.newTab();
tab.setText("Tab2");
tab.setTabListener(this);
bar.addTab(tab);
}
}
При запуске приложения вывод ошибку:
Error:(52, 8) error: duplicate class: startandroid.ru.myschool.MainActivity
Error:Execution failed for task ':app:compileDebugJava'.
Compilation failed; see the compiler error output for details.
Что делаю не так?