나는 이클립스를 설치했고 새로운 소프트웨어 설치 및 sdk 설정을 통해 단계를 수행했습니다. 그러나 MainActivity.java의 오류는 "R을 변수로 해석 할 수 없습니다"입니다. 이것 좀 도와주세요.Eclipse : Android 코드의 "R은 변수로 해결할 수 없습니다"
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hellp"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/This is my first Android Application"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/And this is clickable button!"/>
그것을 저를 @string/This is my first Android Application
를 사용
다음 코드를
package com.home.begingwithandroid;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
감사
입니다XML 코드가
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hellp"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/This is my first Android Application"/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/And this is clickable button!"/>
</LinearLayout>
고전 오류 ... 참조 : http://stackoverflow.com/questions/7824730/r-cannot-be-resolved-to-a-variable http://stackoverflow.com/questions/16642604/eclipse- 오류 -r- 해결할 수없는 변수 http://stackoverflow.com/questions/2757107/developing-for-android-in-eclipse-r-java-not-generating –
나는 그 (것)들 그러나 아무것도는 저를 위해 작동하고있다 – user3440868
그것을 정확하게 시도하십시오, 그것은 작동해야한다 ... –