1

首先,在我写这个问题之前,我做了很多搜索,特别是在这个网站上,但没有找到解决方案。我的问题正如标题所述; 只是在我的程序中有一项活动,这项活动无法找到资源..除此之外,每项活动都可以找到它并且工作正常。我尝试了一切。 “清洁和重建”,” 切换工作空间‘加入’com.myapp.R‘的活动之上,重新下载或关闭/重新打开Eclipse才能’等多..我还检查的bug 。发生在菜单文件夹“main.xml中”,“>”,而不是“/>”反正....请找到一个解决方案感谢活动SetContentView ResourcesNotFound异常

这是我的活动;

import java.text.DecimalFormat; 
import java.text.DecimalFormatSymbols; 

import android.app.Activity; 
import android.app.AlertDialog; 
import android.content.DialogInterface; 
import android.content.pm.ActivityInfo; 
import android.os.Bundle; 
import android.view.View; 
import android.view.View.OnClickListener; 
import android.widget.Button; 
import android.widget.EditText; 
import android.widget.TextView; 

public class Calculator extends Activity { 

public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.calculator); 
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); 

    final DecimalFormat df = new DecimalFormat("0.00000",        DecimalFormatSymbols.getInstance()); 
    DecimalFormatSymbols symbols = new DecimalFormatSymbols(); 
    symbols.setDecimalSeparator('.'); 
    df.setDecimalFormatSymbols(symbols); 

    final EditText et = (EditText) findViewById(R.id.calc_me); 
    final EditText et2 = (EditText) findViewById(R.id.calc_me2); 
    Button copy = (Button) findViewById(R.id.buttonCopy); 
    final TextView tv = (TextView) findViewById(R.id.calc_res); 

    copy.setOnClickListener(new OnClickListener() { 

     @Override 
     public void onClick(View v) { 
      // TODO Auto-generated method stub 
      if(tv.getText().toString().length() >=9) 
      { 
       String s = tv.getText().toString(); 
       s = s.substring(8,s.length()); 
       et.setText(s); 
      } 
     } 
    }); 

这是我的布局,如果需要

<?xml version="1.0" encoding="utf-8"?> 
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:stretchColumns="*"> 

<TableRow android:layout_weight="1"> 
    <EditText 
    android:id="@+id/calc_me" android:layout_width="match_parent"  android:layout_weight="1" 
    android:layout_height="wrap_content" android:textSize="20sp" android:inputType="numberSigned|numberDecimal" /> 
    <EditText 
    android:id="@+id/calc_me2" android:layout_width="match_parent" android:layout_weight="1" 
    android:layout_height="wrap_content" android:textSize="20sp" android:inputType="numberSigned|numberDecimal" /> 
</TableRow> 
<TableRow android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1"> 
    <TextView android:id="@+id/calc_res" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_marginLeft="3dp" android:layout_weight="2" android:textSize="20sp" android:text="Result: "/> 
    <Button android:layout_height="wrap_content" android:id="@+id/buttonCopy" android:text="Copy" android:layout_width="fill_parent"/> 
</TableRow> 
<TableRow android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1"> 
    <Button android:layout_height="wrap_content" android:id="@+id/buttonSquare" android:text="√" android:layout_width="fill_parent"/> 
    <Button android:layout_height="wrap_content" android:id="@+id/buttonPower" android:text="^" android:layout_width="fill_parent"/> 
    <Button android:layout_height="wrap_content" android:id="@+id/buttonPi" android:text="π" android:layout_width="fill_parent"/> 
</TableRow> 
<TableRow android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1"> 
    <Button android:layout_height="wrap_content" android:id="@+id/buttonSin" android:text="sin" android:layout_weight="1" android:layout_width="fill_parent"/> 
    <Button android:layout_height="wrap_content" android:id="@+id/buttonCos" android:text="cos" android:layout_weight="1" android:layout_width="fill_parent"/> 
    <Button android:layout_height="wrap_content" android:id="@+id/buttonTan" android:text="tan" android:layout_weight="1" android:layout_width="fill_parent"/> 
</TableRow> 
<TableRow android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1"> 
    <Button android:layout_height="wrap_content" android:id="@+id/buttonPlus" android:text="+" android:layout_width="fill_parent"/> 
    <Button android:layout_height="wrap_content" android:id="@+id/buttonMinus" android:text="-" android:layout_width="fill_parent"/> 
    <Button android:layout_height="wrap_content" android:id="@+id/buttonTimes" android:text="*" android:layout_width="fill_parent"/> 
</TableRow> 
<TableRow android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1"> 
    <Button android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/buttonLog" android:text="Logb10"/> 
    <Button android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/buttonE" android:text="e"/> 
    <Button android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/buttonDivide" android:text="/"/> 
</TableRow> 


</TableLayout> 
+0

你可以用我的答案完美的工作。 – Harshid

回答

0

嘿把这一行放入您的xml file.actually问题与您的xml文件。

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:stretchColumns="*" > 

测试我的工作perfect.if真的有帮助,然后接受。

+0

谢谢你的答案,但它没有解决它...我发现它是仿真器问题无论如何,因为只有一个模拟器可以运行它,但在真正的手机测试,它的工作.. –

相关问题