第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

Listview不能顯示

Listview不能顯示

qq_我很丑絕緣體_0 2016-07-20 10:18:58
public?class?MainActivity?extends?Activity?{ String[]?object?=?{?"劉備",?"關(guān)羽",?"張飛",?"趙云",?"馬超",?"諸葛亮"?}; @Override protected?void?onCreate(Bundle?savedInstanceState)?{ super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ListView?listView?=?(ListView)?findViewById(R.id.listview1); ArrayAdapter<String>?arrayAdapter?=?new?ArrayAdapter<String>(this, R.layout.item,?object); listView.setAdapter(arrayAdapter); } }mainactivity布局如下:<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:paddingTop="@dimen/activity_vertical_margin" ????tools:context=".MainActivity"?> ????<ListView ????????android:id="@+id/listview1" ????????android:layout_width="match_parent" ????????android:layout_height="match_parent"?> ????</ListView> </RelativeLayout>item布局如下:<?xml?version="1.0"?encoding="utf-8"?> <LinearLayout?xmlns:android="http://schemas.android.com/apk/res/android" ????android:layout_width="match_parent" ????android:layout_height="wrap_content" ????android:orientation="vertical"?> ????<TextView ????????android:layout_width="match_parent" ????????android:layout_height="wrap_content" ????????android:text="哈哈" ????????android:textSize="25sp"?/> </LinearLayout>一運(yùn)行就會(huì)報(bào)錯(cuò),報(bào)出錯(cuò)誤內(nèi)容為:java.lang.ClassCastException:?android.widget.LinearLayout?cannot?be?cast?to?android.widget.TextView剛學(xué)Android求大神指教,這是怎么回事。。?
查看完整描述

2 回答

?
蜂之谷

TA貢獻(xiàn)564條經(jīng)驗(yàn) 獲得超863個(gè)贊

R.layout.item ?改成 ?android.R.layout.simple_list_item_1

查看完整回答
2 反對(duì) 回復(fù) 2016-07-20
?
蕭一郎

TA貢獻(xiàn)20條經(jīng)驗(yàn) 獲得超1個(gè)贊

報(bào)的類轉(zhuǎn)化異常,LinearLayout不能轉(zhuǎn)化為TextView。?

查看完整回答
反對(duì) 回復(fù) 2016-07-21
  • 2 回答
  • 0 關(guān)注
  • 1272 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)