1

私は1つのアクティビティ用のシンプルなAndroidコードを書き、レイアウトフォルダーにsecond.xmlという名前のxmlファイルでそのビューを提供しました。このアクティビティについてもmainfiestファイルで言及しました。 setContentView メソッドでフィールドではありません。解決策を教えてください

import android.R;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ImageView;

public class Second extends Activity
{
    ImageView imageView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.second);

        // Intent i=getIntent();
    }
}
4

3 に答える 3

2

Project-> Cleanからプロジェクトをクリーンアップし、importandroid.Rも削除する必要がありますクリーニングする前にSecondから。src /layout/second.xmlの下にsecond.xmlファイルがあることを確認してください。

import android.app.Activity;
import android.os.Bundle;
import android.widget.ImageView;

public class Second extends Activity
{
    ImageView imageView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.second);

    //      Intent i=getIntent();
  }
}
于 2012-06-04T08:15:30.600 に答える
0

プロジェクトを削除import android.R;してクリーンアップします。Androidが提供するデータを使用しようとしている場合にのみ、android.Rをインポートする必要があります。たとえば、単一行のリストビューを表示するには、Androidが提供するレイアウトとテキストビューを次のように使用します。

ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
    android.R.layout.simple_list_item_1, android.R.id.text1, values);
于 2012-06-04T09:25:25.183 に答える
0

Please Remove the this imported line

import android.R;

then clean just like this:

Go to Project>> clean the project. I think you might be solve your problem; Go to more details: R can not resolve

于 2012-06-04T08:20:40.467 に答える