1

First of all before i wrote this question i had done my search a lot especially in this website but no solution is found. My problem is as the title says; Just for one activity in my program, this activity cant find resources.. Other than it, every activity can find it and works fine. I tried everything; "Clean and rebuild" ,"Switch Workspace" , adding "com.myapp.R" to top of the activity, Redownload or Close/ReOpen Eclipse" and many more.. I also checked the bug happens in menu folder in "main.xml" ">" instead "/>" anyway.... Please find a solution. Thanks

This is my activity;

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);
            }
        }
    });

This is my layout if needed

   <?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>
4

1 回答 1

0

嘿把这一行放在你的xml文件中。实际上你的 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="*" >

经我测试工作完美。如果真的有帮助,请接受。

于 2013-04-02T04:38:31.767 回答