我有以下代码,我正在尝试从 main.xml 检索一个 id,但是 netbeans 显示一个错误,即找不到 id 变量。我看不出我做错了什么,这是代码
<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_gravity="center"
android:layout_width="wrap_content"
android:layout_height="45px"
android:text="Helllo mw "
android:textColor="@color/aqua"
android:id="@+id/my_id2"
/>
</LinearLayout>
我正在尝试在代码中检索 id my_id2 代码
package bomb.com;
import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;
import android.widget.*;
public class MainActivity extends Activity
{
/** Called when the activity is first created. */
Button sup;
TextView uno;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
uno=(TextView)findViewById(R.id.my_id2);
}
}
谢谢 ..