相关疑难解决方法(0)

Android - R级的麻烦

我试图在Android中编写一些基本的东西(listView等).我的问题如下:
1.我写的任何资源(例如指定listView或按钮内容的xml文件)都在R类中注册,但是当我尝试使用它时eclipse将其标记为错误.

例:

相对布局xml文件:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">

  <ListView android:id="@android:id/android:list"
     android:textFilterEnabled="true"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:layout_weight="1"
     android:dividerHeight="3dp"
  />

  <TextView android:id="@+id/simpleText"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="10dp"
    android:textSize="16sp" >
</TextView>

  <Button android:id="@+id/nextButton"
     android:text="@string/next"
     android:layout_height="wrap_content"
     android:layout_width="wrap_content"
     android:layout_alignParentBottom="true"
     android:layout_centerHorizontal="true"
     android:layout_centerVertical="true"
  />

</RelativeLayout>  
Run Code Online (Sandbox Code Playgroud)

代码如下:

public class sample extends ListActivity {
    /** Called when the activity is first created. */

    private Button nxtButton;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Log.v(this.toString(), "Inside the function.");

        nxtButton = (Button)findViewById(R.id.nextButton);
        nxtButton.setOnClickListener(new View.OnClickListener() {   
            @Override
            public void onClick(View v) {
                // …
Run Code Online (Sandbox Code Playgroud)

android android-layout

5
推荐指数
1
解决办法
3584
查看次数

标签 统计

android ×1

android-layout ×1