Android引用图片,找不到资源。 Error: No resource found that matches the given name (at 'src' with.
Activity文件:packagecom.misoo.ex03;importandroid.app.Activity;importandroid.os.Bundle;i...
Activity文件:
package com.misoo.ex03;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
public class Ex03Activity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageButton btn = (ImageButton)findViewById(R.id.button);
ImageButton btn2 = (ImageButton)findViewById(R.id.button2);
OnClickListener listener = new OnClickListener()
{
public void onClick(View v)
{
setTitle("this is OK button..Pro3..");
}
};
OnClickListener listener2 = new OnClickListener()
{
public void onClick(View v1)
{
finish();
}
};
btn.setOnClickListener(listener);
btn2.setOnClickListener(listener2);
}
}
---------------------------------------------
main.xml :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<ImageButton android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable-hdpi/OK"
/>
<ImageButton android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable-hdpi/Exit"
/>
</LinearLayout>
===========
显示错误:Error: No resource found that matches the given name (at 'src' with value '@drawable-hdpi/OK').
而且 ImageButton btn = (ImageButton)findViewById(R.id.button);
ImageButton btn2 = (ImageButton)findViewById(R.id.button2);
两句中 id 也是红下划线,表示是未知的。。
怎么解决啊? 展开
package com.misoo.ex03;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
public class Ex03Activity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageButton btn = (ImageButton)findViewById(R.id.button);
ImageButton btn2 = (ImageButton)findViewById(R.id.button2);
OnClickListener listener = new OnClickListener()
{
public void onClick(View v)
{
setTitle("this is OK button..Pro3..");
}
};
OnClickListener listener2 = new OnClickListener()
{
public void onClick(View v1)
{
finish();
}
};
btn.setOnClickListener(listener);
btn2.setOnClickListener(listener2);
}
}
---------------------------------------------
main.xml :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<ImageButton android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable-hdpi/OK"
/>
<ImageButton android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable-hdpi/Exit"
/>
</LinearLayout>
===========
显示错误:Error: No resource found that matches the given name (at 'src' with value '@drawable-hdpi/OK').
而且 ImageButton btn = (ImageButton)findViewById(R.id.button);
ImageButton btn2 = (ImageButton)findViewById(R.id.button2);
两句中 id 也是红下划线,表示是未知的。。
怎么解决啊? 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询