我在 Eclipse 中有一些非常独特的错误。所以这就是发生的事情:在我的 Android 应用程序(在 Eclipse 中)中,我有所有这些滑动菜单错误和其他相关错误。我无法弄清楚如何修复这些错误,因为我是一个完整的 nube。这是我的代码:
package ws.stefma.nguide;
import java.util.ArrayList;
import android.app.Activity;
import android.graphics.Point;
import android.os.Bundle;
import android.util.Log;
import android.view.Display;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.ScrollView;
import android.widget.TextView;
public class Activity_Start<SlidingMenu> extends Activity {
SlidingMenu slidingMenu;
boolean check = true;
Menu menu;
public static ArrayList<String> chapterContentList = new ArrayList<String>();
/*
* IMPORTANT
* INSERT HERE YOUR CHAMPTERS NAME
* THESE NAMES ARE SHOING ON THE LEFT SITE OF THE APP
* IN THE SLIDINGMENU!!
*
* USE THIS NAMES IN YOUR STRINGS.XML TOO!!
*/
ArrayList<String> chapterList = new ArrayList<String>() {{
add("Linux");
add("Android");
add("Debian");
}};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_start);
getActionBar().setHomeButtonEnabled(true);
getActionBar().setDisplayHomeAsUpEnabled(true);
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
slidingMenu = new SlidingMenu(this);
slidingMenu.setMode(SlidingMenu.LEFT);
slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
slidingMenu.setShadowWidth(5);
slidingMenu.setFadeDegree(0.35f);
slidingMenu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
slidingMenu.setBehindWidth(width-width/3);
slidingMenu.setFadeEnabled(true);
slidingMenu.setMenu(R.layout.slidingmenu);
ListView lv = (ListView) findViewById(R.id.lv);
ListAdapter listenAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, chapterList);
lv.setAdapter(listenAdapter);
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView av, View v, int i, long l) {
switch(i) {
case 0:
new Task_SplitText(Activity_Start.this, chapterList.get(i), menu).execute();
slidingMenu.showContent();
check = true;
break;
case 1:
new Task_SplitText(Activity_Start.this, chapterList.get(i), menu).execute();
slidingMenu.showContent();
check = true;
break;
case 2:
new Task_SplitText(Activity_Start.this, chapterList.get(i), menu).execute();
slidingMenu.showContent();
check = true;
break;
}
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
this.menu = menu;
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.activity_start, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
LinearLayout ll = (LinearLayout) findViewById(R.id.linearlayout);
TextView tv = (TextView) ll.getChildAt(0);
int q = 0;
for(q = 0; q < chapterContentList.size(); q += 1) {
Log.e("Liste2", chapterContentList.get(q));
if(chapterContentList.get(q).equals(tv.getText().toString())) {
Log.e("chapterContenList", chapterContentList.get(q));
Log.e("tvgetText", tv.getText().toString());
break;
}
}
Log.e("hallo", String.valueOf(q));
switch(item.getItemId()) {
case android.R.id.home:
if(check) {
slidingMenu.showMenu();
check = false;
} else {
slidingMenu.showContent();
check = true;
}
return true;
case R.id.menu_previous:
MenuItem pageItem = menu.findItem(R.id.menu_page);
String[] x = pageItem.getTitle().toString().split("/");
try {
int page = Integer.parseInt(x[0]);
page -= 1;
pageItem.setTitle(page+"/"+x[1]);
} catch(Exception exe) {
exe.printStackTrace();
}
ll.removeAllViews();
ScrollView sv = (ScrollView) findViewById(R.id.scrollview);
sv.fullScroll(View.FOCUS_UP);
while(!chapterContentList.get(q).equals("END")) {
q -= 1;
}
q -= 1;
while(!chapterContentList.get(q).equals("END")) {
q -= 1;
if(q == -1) {
break;
}
Log.e("q", String.valueOf(q));
}
q = q + 1;
while(!chapterContentList.get(q).equals("END")) {
if(chapterContentList.get(q).contains("IMAGENAME")) {
// Create ImageView
String imagename = chapterContentList.get(q).replaceAll("--", "").replaceAll("IMAGENAME", "");
ImageView iv = new ImageView(this);
int j = getResources().getIdentifier(imagename, "drawable", getPackageName());
iv.setImageResource(j);
ll.addView(iv);
} else {
// Create TextView
TextView tvNew = new TextView(this);
tvNew.setText(chapterContentList.get(q));
ll.addView(tvNew);
}
q += 1;
Log.e("q2", String.valueOf(q));
}
return true;
case R.id.menu_next:
MenuItem pageItem2 = menu.findItem(R.id.menu_page);
String[] x2 = pageItem2.getTitle().toString().split("/");
try {
int page = Integer.parseInt(x2[0]);
page += 1;
pageItem2.setTitle(page+"/"+x2[1]);
} catch(Exception exe) {
exe.printStackTrace();
}
ll.removeAllViews();
ScrollView sv2 = (ScrollView) findViewById(R.id.scrollview);
sv2.fullScroll(View.FOCUS_UP);
while(!chapterContentList.get(q).equals("END")) {
q += 1;
}
q += 1;
while(!chapterContentList.get(q).equals("END")) {
if(chapterContentList.get(q).contains("IMAGENAME")) {
// Create ImageView
String imagename = chapterContentList.get(q).replaceAll("--", "").replaceAll("IMAGENAME", "");
ImageView iv = new ImageView(this);
int j = getResources().getIdentifier(imagename, "drawable", getPackageName());
iv.setImageResource(j);
ll.addView(iv);
} else {
// Create TextView
TextView tvNew = new TextView(this);
tvNew.setText(chapterContentList.get(q));
ll.addView(tvNew);
}
q += 1;
}
return true;
default:
return true;
}
}
}
错误如下
1.Description Resource Path Location Type
TOUCHMODE_FULLSCREEN cannot be resolved or is not a field Activity_Start.java /NGuide/src/ws/stefma/nguide line 62 Java Problem
2.Description Resource Path Location Type
The method showMenu() is undefined for the type SlidingMenu Activity_Start.java /NGuide/src/ws/stefma/nguide line 126 Java Problem
3.Description Resource Path Location Type
The method showContent() is undefined for the type SlidingMenu Activity_Start.java /NGuide/src/ws/stefma/nguide line 129 Java Problem
4.Description Resource Path Location Type
LEFT cannot be resolved or is not a field Activity_Start.java /NGuide/src/ws/stefma/nguide line 61 Java Problem
5.Cannot instantiate the type SlidingMenu Activity_Start.java /NGuide/src/ws/stefma/nguide line 60 Java Problem
6.The method showContent() is undefined for the type SlidingMenu Activity_Start.java /NGuide/src/ws/stefma/nguide line 84 Java Problem
7.The method showContent() is undefined for the type SlidingMenu Activity_Start.java /NGuide/src/ws/stefma/nguide line 89 Java Problem
8.The method showContent() is undefined for the type SlidingMenu Activity_Start.java /NGuide/src/ws/stefma/nguide line 79 Java Problem
9.The method setFadeEnabled(boolean) is undefined for the type SlidingMenu Activity_Start.java /NGuide/src/ws/stefma/nguide line 67 Java Problem
10.The method setMenu(int) is undefined for the type SlidingMenu Activity_Start.java /NGuide/src/ws/stefma/nguide line 68 Java Problem
11.SLIDING_CONTENT cannot be resolved or is not a field Activity_Start.java /NGuide/src/ws/stefma/nguide line 65 Java Problem
12.The method setBehindWidth(int) is undefined for the type SlidingMenu Activity_Start.java /NGuide/src/ws/stefma/nguide line 66 Java Problem
13.The method setShadowWidth(int) is undefined for the type SlidingMenu Activity_Start.java /NGuide/src/ws/stefma/nguide line 63 Java Problem
14.The method setFadeDegree(float) is undefined for the type SlidingMenu Activity_Start.java /NGuide/src/ws/stefma/nguide line 64 Java Problem