Tôi biết câu hỏi này đã được hỏi nhiều lần, nhưng không có câu trả lời nào hữu ích do ngữ cảnh của tôi. Vấn đề là, tôi vừa mở dự án đầu tiên của tôi (trong máy tính thực tế của tôi) và không sửa bất cứ điều gì tất cả các "R." trong mainActivity.java chuyển sang màu đỏ. Có ai biết nguyên nhân của vấn đề này là gì và nó có thể được khắc phục như thế nào?Android Studio: không thể phân giải biểu tượng "R"
Đây là hoạt động chính java
package com.nico.calc_02;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
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.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();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
và đây là cách bố trí .xml:
<RelativeLayout 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:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
<TextView android:text="@string/hello_world" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
tôi đã không sửa đổi mã hoặc bất cứ điều gì. Tôi đang sử dụng Android Studio. Có ai biết làm thế nào để khắc phục nó?
Hãy thử điều này [Giải pháp] [1] nó có thể giải quyết vấn đề của bạn [1]: http://stackoverflow.com/a/32119880/3343174 – Fakher
Hãy thử điều này [Giải pháp] [1] nó có thể giải quyết vấn đề của bạn. [1]: http://stackoverflow.com/a/32119880/3343174 – Fakher