定义了一个PersonListView类如下:
public class PersonListView extends ListView
{
public PersonListView(Context context, AttributeSet attrs) {
super(context, attrs);
}
}res/layout/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">
<View
class="com.study.android.activity.MainActivity$PersonListView"
android:id="@+id/lv_person"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>MainActivity的onCreate方法:
setContentView(R.layout.main);
lv_item = (PersonListView) findViewById(R.id.lv_person);错误为:lv_item = (PersonListView) findViewById(R.id.lv_person)出现了ClassCastException请问前面的写法哪里出了问题吗
public class PersonListView extends ListView
{
public PersonListView(Context context, AttributeSet attrs) {
super(context, attrs);
}
}res/layout/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">
<View
class="com.study.android.activity.MainActivity$PersonListView"
android:id="@+id/lv_person"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>MainActivity的onCreate方法:
setContentView(R.layout.main);
lv_item = (PersonListView) findViewById(R.id.lv_person);错误为:lv_item = (PersonListView) findViewById(R.id.lv_person)出现了ClassCastException请问前面的写法哪里出了问题吗
解决方案 »
- ProgressDialog的问题,求解
- 是大神就来瞧瞧-------EditText多行显示时,在行末输入空格不会自动换行问题!!!!!!!!!!
- 怎么查看RadioButton是否被选中了
- 基于android平台如何根据商品的条形码来查询该商品价格?
- 媒体数据库标题索引乱码怎么办?
- android中使用webview加载html页面的问题
- android开发java平台问题
- 如何实现一个gridview的特殊布局
- listview的getView里面返回LinearLayout,为何报错了?
- 从SVN 检出 输入 URL 后弹出 “无法验证” 验证位置时发生错误:org.apache.svbversion.javahl.ClientException
- 谁有c2dm的相关资料,最好有实例
- AlertDialog.Builder listview SimpleCursorAdapter删除项问题
<包名.PersonListView
android:id="@+id/lv_person"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
并不是类型转换的问题
内部类必须要用外部类的对象来new 才能创建对象