我正在 android 上创建简单的计算程序/应用程序,这是自动生成的错误来自 public static final int 13687=0x7f020000;
这是代码: src>java :
public class FirstAct extends Activity {
int counter;
int i;
Button plus,minus,x,Divide;
TextView Show;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_first);
counter =0;
i=1;
plus = (Button) findViewById(R.id.xadd); //buttons in java
minus =(Button) findViewById(R.id.xsub);
x = (Button) findViewById(R.id.xmultiply);
Divide = (Button) findViewById(R.id.xdivide);
Show = (TextView) findViewById(R.id.xtv2);
plus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
counter++;
}
});
minus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
counter--;
Show.setText("Total ="+counter);
}
});
x.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
counter*=i;
i++;
Show.setText("Total ="+counter);
}
});
Divide.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
counter/=i;
i++;
Show.setText("Total ="+counter);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.first, menu);
return true;
}
}
这是 gen>R>java 代码
public static final int activity_horizontal_margin=0x7f050000;
public static final int activity_vertical_margin=0x7f050001;
}
public static final class drawable {
public static final int 13687=0x7f020000; //error here it is?? WHY
public static final int ic_launcher=0x7f020001;
}
public static final class id {
public static final int action_settings=0x7f090006;
public static final int xadd=0x7f090001;
public static final int xdivide=0x7f090004;
public static final int xmultiply=0x7f090003;
public static final int xsub=0x7f090002;
public static final int xtv1=0x7f090000;
public static final int xtv2=0x7f090005;
}
public static final class layout {
public static final int activity_first=0x7f030000;
}
public static final class menu {
public static final int first=0x7f080000;
}
public static final class raw {
public static final int sunrahahai=0x7f040000;
}
public static final class string {
public static final int Total=0x7f060003;
public static final int Wel=0x7f060002;
public static final int action_settings=0x7f060001;
public static final int app_name=0x7f060000;
public static final int del=0x7f060005;
public static final int div=0x7f060006;
public static final int mul=0x7f060007;
public static final int sum=0x7f060004;
}
public static final class style {
/**
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
*/
public static final int AppBaseTheme=0x7f070000;
/** Application theme.
All customizations that are NOT specific to a particular API-level can go here.
*/
public static final int AppTheme=0x7f070001;
}
}
这是 XML 代码:
<LinearLayout 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:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".FirstAct" >
<TextView
android:id="@+id/xtv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Wel" />
<Button
android:id="@+id/xadd"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:text="@string/sum"
android:textSize="20sp" />
<Button
android:id="@+id/xsub"
android:layout_width="147dp"
android:layout_height="wrap_content"
android:text="@string/del"
android:textSize="20sp" />
<Button
android:id="@+id/xmultiply"
android:layout_width="143dp"
android:layout_height="wrap_content"
android:layout_marginRight="26dp"
android:text="@string/mul"
android:textSize="20sp" />
<Button
android:id="@+id/xdivide"
android:layout_width="144dp"
android:layout_height="wrap_content"
android:text="@string/div"
android:textSize="20sp" />
<TextView
android:id="@+id/xtv2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="44dp"
android:layout_marginRight="14dp"
android:text="@string/Total"
android:textSize="20sp" />
</LinearLayout>