Ich versuche, eine Tutorial-App zu erstellen. Ich bin eine NachrichtAndroid Studio Navigationsschublade - Ausdruck erwartet
Ausdruck sagen immer erwartet
unter
case 2:
Activity = new Lesson111();
break;
Hinweis - Dies ist nicht der ganze Code meiner Haupttätigkeit ist. Allerdings beginnt das Problem, wenn ich
case 2:
fragment = new Lesson111();
break;
zu
case 2:
Activity = new Lesson111();
break;
Hier ändern ist mein Main.Activity:
public class NavigationActivity extends FragmentActivity {
private DrawerLayout mDrawerLayout;
ImageView home;
Fragment fragment = null;
TextView appname;
ExpandableListView expListView;
HashMap<String, List<String>> listDataChild;
ExpandableListAdapter listAdapter;
List<String> listDataHeader;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_navigation);
home = (ImageView)findViewById(R.id.home);
home.setOnClickListener(homeOnclickListener);
appname = (TextView)findViewById(R.id.appname);
setUpDrawer();
}
/**
*
* Get the names and icons references to build the drawer menu...
*/
private void setUpDrawer() {
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerLayout.setScrimColor(getResources().getColor(android.R.color.transparent));
mDrawerLayout.setDrawerListener(mDrawerListener);
expListView = (ExpandableListView) findViewById(R.id.lvExp);
prepareListData();
listAdapter = new ExpandableListAdapter(this, listDataHeader, listDataChild);
// setting list adapter
expListView.setAdapter(listAdapter);
fragment = new Lesson1();
getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, fragment).commit();
mDrawerLayout.closeDrawer(expListView);
expListView.setOnChildClickListener(new OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
switch (groupPosition) {
case 0:
switch (childPosition) {
case 0:
fragment = new Lesson1();
break;
case 1:
fragment = new Lesson11();
break;
case 2:
Activity = new Lesson111();
break;
default:
break;
}
break;
Sie haben keine Aktivitätsvariable initialisiert. Versuchen Sie etwas wie Aktivität activity = new Lesson111(); –
Ich habe versucht, was du gesagt hast. Allerdings sagt es Inkompatible Typen. Auch die "Aktivität" ist ausgegraut. Und es sagt auch - Erforderlich: android.app.Activity Gefunden: com.android.pet.view.Lesson111 –
Weil Sie tatsächlich eine Activity-Instanz instanziiert. Momentan hängt es einfach dort. Was versuchst du zu erreichen? Aktualisieren Sie Ihre Frage mit mehr Informationen bitte –