Suddently," R.java"从我英寸时删除;复选框"程序? [英] Suddently, "R.java" was deleted from my "CheckBox" program?

查看:124
本文介绍了Suddently," R.java"从我英寸时删除;复选框"程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我学习的Andr​​oid(我是初学者),使一个程序复选框。结果
一切似乎都很好,但是当我清理我的项目突然,R.java被删除,它给了一个错误。结果
我检查三次,但没有得到它回来了。

I'm learning Android (I'm a beginner) and making a program for CheckBox.
Everything seems fine, but when I cleaned my project suddenly, R.java was deleted and it's giving an error.
I checked three times, but not getting it back.

下面是我的源$ C ​​$ C:

Here is my source code:

activity_main.xml中

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <CheckBox
        android:id="@+id/checkBox1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="IPhone" />

    <CheckBox
        android:id="@+id/checkBox2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Android" 
        android:checked="true"/>

    <CheckBox
        android:id="@+id/checkBox3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Windows Mobile"
        android:checked="false"/>

    <Button
        android:id="@+id/btn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Display" />

</LinearLayout>

MainActivity.java

package com.example.lesson06;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.Toast;

public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        addListenerOnButton();
        addListenerOnChkbox();
    }
    public void addListenerOnChkbox(){
        CheckBox chkbx=(CheckBox)findViewById(R.id.checkBox1);
        chkbx.setOnClickListener(new OnClickListener(){

            public void onClick(View v){
                if(((CheckBox) v).isChecked()){
                    Toast.makeText(MainActivity.this, "Bro..try Android :)", Toast.LENGTH_LONG);
                }
            }
        });
    }

    public void addListenerOnButton(){
        final CheckBox chkbx=(CheckBox)findViewById(R.id.checkBox1);
        final CheckBox chkbx2=(CheckBox)findViewById(R.id.checkBox2);
        final CheckBox chkbx3=(CheckBox)findViewById(R.id.checkBox3);
        final Button btn=(Button)findViewById(R.id.btn);

        btn.setOnClickListener(new OnClickListener(){
            public void onClick(View v){
                StringBuffer result=new StringBuffer();
                result.append("IPhone check: ").append(chkbx.isChecked());
                result.append("\nAndroid check: ").append(chkbx2.isChecked());
                result.append("\nWindows Mobile Check: ").append(chkbx3.isChecked());

                Toast.makeText(MainActivity.this, result.toString(), Toast.LENGTH_LONG).show();
            }
        });
    }
}

任何帮助将大大AP preciated。

Any help would be greatly appreciated.

推荐答案

您按钮标签未关闭进 activity_main.xml中

<Button
        android:id="@+id/btn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Display"

关闭了

<Button
        android:id="@+id/btn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Display" />

和清洁工程。你的 R.java 类将会产生。

and clean project. Your R.java class will be generated.

这篇关于Suddently,&QUOT; R.java&QUOT;从我英寸时删除;复选框&QUOT;程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆