我的日志猫
12-07 16:50:54.896: E/AndroidRuntime(1697): FATAL EXCEPTION: main
12-07 16:50:54.896: E/AndroidRuntime(1697): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.blackcat.blackcattourorganizer/com.blackcat.blackcattourorganizer.showBudgetActivity}: android.content.res.Resources$NotFoundException: String resource ID #0xc80
12-07 16:50:54.896: E/AndroidRuntime(1697): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
12-07 16:50:54.896: E/AndroidRuntime(1697): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
12-07 16:50:54.896: E/AndroidRuntime(1697): at android.app.ActivityThread.access$600(ActivityThread.java:141)
12-07 16:50:54.896: E/AndroidRuntime(1697): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
12-07 16:50:54.896: E/AndroidRuntime(1697): at android.os.Handler.dispatchMessage(Handler.java:99)
12-07 16:50:54.896: E/AndroidRuntime(1697): at android.os.Looper.loop(Looper.java:137)
12-07 16:50:54.896: E/AndroidRuntime(1697): at android.app.ActivityThread.main(ActivityThread.java:5103)
12-07 16:50:54.896: E/AndroidRuntime(1697): at java.lang.reflect.Method.invokeNative(Native Method)
12-07 16:50:54.896: E/AndroidRuntime(1697): at java.lang.reflect.Method.invoke(Method.java:525)
12-07 16:50:54.896: E/AndroidRuntime(1697): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
12-07 16:50:54.896: E/AndroidRuntime(1697): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
12-07 16:50:54.896: E/AndroidRuntime(1697): at dalvik.system.NativeStart.main(Native Method)
12-07 16:50:54.896: E/AndroidRuntime(1697): Caused by: android.content.res.Resources$NotFoundException: String resource ID #0xc80
12-07 16:50:54.896: E/AndroidRuntime(1697): at android.content.res.Resources.getText(Resources.java:239)
12-07 16:50:54.896: E/AndroidRuntime(1697): at android.widget.TextView.setText(TextView.java:3844)
12-07 16:50:54.896: E/AndroidRuntime(1697): at com.blackcat.blackcattourorganizer.showBudgetActivity.onCreate(showBudgetActivity.java:50)
12-07 16:50:54.896: E/AndroidRuntime(1697): at android.app.Activity.performCreate(Activity.java:5133)
12-07 16:50:54.896: E/AndroidRuntime(1697): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
12-07 16:50:54.896: E/AndroidRuntime(1697): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
12-07 16:50:54.896: E/AndroidRuntime(1697): ... 11 more
现在确定没有打开的活动代码
public class showBudgetActivity extends Activity {
TextView sb1, sb2, sb3, sb4, sb5, sb_r;
Button showBudget_backButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.showbudget_activity);
sb_r = (TextView) findViewById(R.id.textView_showBudget_rBudget);
sb1 = (TextView) findViewById(R.id.textView_SB_H2);
sb2 = (TextView) findViewById(R.id.textView_SB_T2);
sb3 = (TextView) findViewById(R.id.textView_SB_F2);
sb4 = (TextView) findViewById(R.id.textView_SB_S2);
sb5 = (TextView) findViewById(R.id.textView_SB_O2);
showBudget_backButton = (Button) findViewById(R.id.button_showBudget);
tourDB gettingInfo = new tourDB(this);
gettingInfo.open();
long getlastID = gettingInfo.getMaxID();
int prev_remainbudget = gettingInfo.getPrevRemainBudget(getlastID);
int prev_rent = gettingInfo.getRentPrev(getlastID);
int prev_transport = gettingInfo.getTransportPrev(getlastID);
int prev_food = gettingInfo.getFoodPrev(getlastID);
int prev_shopping = gettingInfo.getShoppingPrev(getlastID);
int prev_other = gettingInfo.getOtherPrev(getlastID);
gettingInfo.close();
sb_r.setText(prev_remainbudget);
sb1.setText(String.valueOf(prev_rent));
sb2.setText(String.valueOf(prev_transport));
sb3.setText(String.valueOf(prev_food));
sb4.setText(String.valueOf(prev_shopping));
sb5.setText(String.valueOf(prev_other));
showBudget_backButton.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v)
{
Intent openonGoingActivity = new Intent("com.blackcat.blackcattourorganizer.ONGOINGACTIVITY");
startActivity(openonGoingActivity);
}
});
//fetchdatafromDataBase();
}
/*private void fetchdatafromDataBase() {
}*/
}
现在这是我正在调用Activity
的类public class onGoingActivity extends ListActivity{
static final String onGoingList[] = {"Enter Expenses","Remaining Budget","Click Photos","Close Tour Profile","Back"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setListAdapter(new onGoingArrayAdapter(this, onGoingList));
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
String positionItem = (String) getListAdapter().getItem(position);
if (positionItem.contentEquals("Enter Expenses")) {
//mainMenuActivityItem = "createNewActivity_1";
Intent openActivity = new Intent("com.blackcat.blackcattourorganizer.EXPENSELISTACTIVITY");
startActivity(openActivity);
}else if (positionItem.contentEquals("Remaining Budget")) {
//mainMenuActivityItem = "onGoingActivity";
Intent openActivity = new Intent("com.blackcat.blackcattourorganizer.SHOWBUDGETACTIVITY");
startActivity(openActivity);
}else if (positionItem.contentEquals("Click Photos")) {
//mainMenuActivityItem = "tourListActivity";
Intent openActivity = new Intent("com.blackcat.blackcattourorganizer.PHOTOUPACTIVITY");
startActivity(openActivity);
}else if (positionItem.contentEquals("Famous Tourist Attractions")) {
//mainMenuActivityItem = "famousTourActivity";
Intent openActivity = new Intent("com.blackcat.blackcattourorganizer.CLOSEPROFILEACTIVITY");
startActivity(openActivity);
}else if (positionItem.contentEquals("Back")) {
//mainMenuActivityItem = "alarmSetActivity";
Intent openMainActivity = new Intent("com.blackcat.blackcattourorganizer.MAINACTIVITY");
startActivity(openMainActivity);
}
/*
if (selectExpense == "back"){
Intent openMainActivity = new Intent("com.blackcat.blackcattourorganizer.MAINACTIVITY");
startActivity(openMainActivity);
}
else {
try{
Class onGoingClass = Class.forName("com.blackcat.blackcattourorganizer." + selectExpense);
Intent selectExpenseIntent = new Intent(onGoingActivity.this, onGoingClass);
startActivity(selectExpenseIntent);
}catch(ClassNotFoundException e){
e.printStackTrace();
}
}*/
}
}
清单非常好。
答案 0 :(得分:0)
您忘记为String.valueOf()
sb_r
TextView
了
简单地说:
sb_r.setText(String.valueOf(prev_remainbudget));
TextView的setText()
方法尝试查找与该数字匹配的资源ID,如果给它一个任意的int值,它将找不到资源,因此Exception
,
答案 1 :(得分:0)
看起来您正在引用不存在的资源,请检查资源中存在的代码中的所有R.x用法
android.content.res.Resources$NotFoundException: String resource ID #0xc80