まず、この質問を書く前に、特にこの Web サイトで多くの検索を行いましたが、解決策が見つかりません。私の問題は、タイトルが示すとおりです。私のプログラムの 1 つのアクティビティだけで、このアクティビティはリソースを見つけることができません。それ以外は、すべてのアクティビティがそれを見つけることができ、正常に動作します。私はすべてを試しました。「クリーンと再構築」、「ワークスペースの切り替え」 、アクティビティの先頭への「 com.myapp.R 」の追加、 Eclipse の再ダウンロードまたはクローズ/再オープン」など。「メインのメニュー フォルダーでバグが発生することも確認しました。 xml" ">" 代わりに "/>" とにかく....解決策を見つけてください。ありがとう
これが私の活動です。
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>