问题描述
有谁看到为什么我的应用程序崩溃时,我尝试用一个ListView加载这个页面?
也许一个简单的办法,但我是新和不知道什么是错!
试图重复scorecard_row在ListView,然后使用ArrayAdapter填充每一行文字1-18,应该很容易!但是当我运行应用程序,并单击它崩溃的页面上!
如果我改变这一行:
ArrayAdapter适配器=新ArrayAdapter<串GT;(这一点,R.layout.scorecard_row,R.id.txtHoleNum,价值观);
到
ArrayAdapter适配器=新ArrayAdapter<串GT;(这一点,android.R.layout.simple_list_item_1,android.R.id.text1,价值观);
它会成功地与递增的数字显示股票的android列表项。
任何帮助是极大AP preciated,硬是卡在本作5+小时
PlayActivity:
进口java.io.IOException异常;
进口的java.util.ArrayList;进口android.app.Activity;
进口android.app.ActionBar;
进口android.app.Fragment;
进口android.database.SQLException;
进口android.os.Bundle;
进口android.view.LayoutInflater;
进口android.view.Menu;
进口android.view.MenuItem;
进口android.view.View;
进口android.view.ViewGroup;
进口android.widget.ArrayAdapter;
进口android.widget.ListView;
进口android.os.Build;公共类PlayActivity延伸活动{私人的ListView列表视图;@覆盖
保护无效的onCreate(捆绑savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.activity_play); //从XML列表视图对象
列表视图=(ListView控件)findViewById(R.id.listviewSC); 串[]值=新串[] {1,2,3,4,5,6,7,8,9,10, 11,12,13,14,15,16,17,18};
//的String [] parValues;
// ScorecardAdapter适配器=新ScorecardAdapter(这一点,值);
ArrayAdapter适配器=新ArrayAdapter<串GT;(这一点,R.layout.scorecard_row,R.id.txtHoleNum,价值观);
//分配适配器列表视图
listview.setAdapter(适配器);}@覆盖
公共布尔onCreateOptionsMenu(菜单菜单){ //充气菜单;如果是present这增加了项目操作栏。
。getMenuInflater()膨胀(R.menu.play,菜单);
返回true;
}@覆盖
公共布尔onOptionsItemSelected(菜单项项){
//处理动作栏项目点击这里。操作栏会
//自动处理上点击主页/向上按钮,只要
//你在AndroidManifest.xml中指定一个父活动。
INT ID = item.getItemId();
如果(ID == R.id.action_settings){
返回true;
}
返回super.onOptionsItemSelected(项目);
}公共无效的onSave(){
DataBaseHelper myDbHelper;
myDbHelper =新DataBaseHelper(本); 尝试{
myDbHelper.createDataBase();
}赶上(IOException异常IOE){
抛出新的错误(无法创建数据库);
} 尝试{
myDbHelper.openDataBase();
}赶上(的SQLException SQLE){
扔SQLE;
}
}
}
scorecard_row.xml:
<?XML版本=1.0编码=UTF-8&GT?;
<的RelativeLayout的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT><的TextView
机器人:ID =@ + ID / textView1
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentLeft =真
机器人:layout_alignParentTop =真
机器人:layout_marginTop =17dp
机器人:文字=洞
机器人:textAppearance =:/>中的Android ATTR / textAppearanceSmall?<的TextView
机器人:ID =@ + ID / txtHoleNum
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentLeft =真
机器人:layout_below =@ + ID / textView1
机器人:文字=12
机器人:textAppearance =机器人:ATTR / textAppearanceLarge
机器人:文字颜色=@风格/ RText/><的TextView
机器人:ID =@ + ID / textView2
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignBaseline =@ + ID / textView1
机器人:layout_alignBottom =@ + ID / textView1
机器人:layout_marginLeft =15dp
机器人:layout_toRightOf =@ + ID / textView1
机器人:文字=相提并论
机器人:textAppearance =:/>中的Android ATTR / textAppearanceSmall?<的TextView
机器人:ID =@ + ID / txtPar
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignBaseline =@ + ID / txtHoleNum
机器人:layout_alignBottom =@ + ID / txtHoleNum
机器人:layout_alignLeft =@ + ID / textView2
机器人:文字=4
机器人:textAppearance =:/>中的Android ATTR / textAppearanceLarge?<复选框
机器人:ID =@ + ID / cbGIR
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignBaseline =@ + ID / textView2
机器人:layout_alignBottom =@ + ID / textView2
机器人:layout_marginLeft =18dp
机器人:layout_toRightOf =@ + ID / textView2
机器人:文字=GIR/><复选框
机器人:ID =@ + ID / cbFW
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignLeft =@ + ID / cbGIR
机器人:layout_below =@ + ID / cbGIR
机器人:文字=FW/><的TextView
机器人:ID =@ + ID / textView3
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignBottom =@ + ID / textView2
机器人:layout_marginLeft =22dp
机器人:layout_toRightOf =@ + ID / cbGIR
机器人:文字=推杆
机器人:textAppearance =:/>中的Android ATTR / textAppearanceSmall?<的EditText
机器人:ID =@ + ID / editText1
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignLeft =@ + ID / textView3
机器人:layout_below =@ + ID / textView4
机器人:EMS =3
安卓的inputType =数字
机器人:maxEms =3/><的EditText
机器人:ID =@ + ID / editText2
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignBaseline =@ + ID / editText1
机器人:layout_alignBottom =@ + ID / editText1
机器人:layout_alignParentRight =真
机器人:EMS =3
安卓的inputType =数字
机器人:maxEms =3> < requestFocus的/>
< /&的EditText GT;<的TextView
机器人:ID =@ + ID / textView4
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignBaseline =@ + ID / textView3
机器人:layout_alignBottom =@ + ID / textView3
机器人:layout_alignParentRight =真
机器人:文字=得分
机器人:textAppearance =:/>中的Android ATTR / textAppearanceLarge?< / RelativeLayout的>
编辑:
LogCat中堆栈跟踪
18 04-11:59:55.900:D / AbsListView(2023):获得MotionRecognitionManager
04-11 18:59:55.905:D / AbsListView(2023):onVisibilityChanged()被调用,能见度:4
04-11 18:59:55.905:D / AbsListView(2023):unregisterIRListener()被调用
04-11 18:59:55.910:D / AbsListView(2023):onVisibilityChanged()被调用,能见度:0
04-11 18:59:55.910:D / AbsListView(2023):unregisterIRListener()被调用
04-11 18:59:55.920:D / AndroidRuntime(2023):关闭VM
04-11 18:59:55.920:W / dalvikvm(2023):主题ID = 1:螺纹未捕获的异常退出(组= 0x41caa700)
04-11 18:59:55.930:E / AndroidRuntime(2023):致命异常:主要
04-11 18:59:55.930:E / AndroidRuntime(2023):android.view.InflateException:二进制XML文件行#16:错误充气类<&不明GT;
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.view.LayoutInflater.createView(LayoutInflater.java:626)
04-11 18:59:55.930:E / AndroidRuntime(2023):在com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.view.LayoutInflater.onCreateView(LayoutInflater.java:675)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:700)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.view.LayoutInflater.inflate(LayoutInflater.java:498)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.view.LayoutInflater.inflate(LayoutInflater.java:398)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:371)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.widget.ArrayAdapter.getView(ArrayAdapter.java:362)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.widget.AbsListView.obtainView(AbsListView.java:2627)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.widget.ListView.measureHeightOfChildren(ListView.java:1259)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.widget.ListView.onMeasure(ListView.java:1171)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.view.View.measure(View.java:16831)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5245)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1410)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.view.View.measure(View.java:16831)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5245)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.view.View.measure(View.java:16831)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5245)
04-11 18:59:55.930:E / AndroidRuntime(2023):在com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:302)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.view.View.measure(View.java:16831)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5245)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
04-11 18:59:55.930:E / AndroidRuntime(2023):在com.android.internal.policy.impl.PhoneWindow $ DecorView.onMeasure(PhoneWindow.java:2586)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.view.View.measure(View.java:16831)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2189)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1352)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1535)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1249)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.view.ViewRootImpl $ TraversalRunnable.run(ViewRootImpl.java:6364)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.view.Choreographer $ CallbackRecord.run(Choreographer.java:791)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.view.Choreographer.doCallbacks(Choreographer.java:591)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.view.Choreographer.doFrame(Choreographer.java:561)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.view.Choreographer $ FrameDisplayEventReceiver.run(Choreographer.java:777)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.os.Handler.handleCallback(Handler.java:730)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.os.Handler.dispatchMessage(Handler.java:92)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.os.Looper.loop(Looper.java:137)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.app.ActivityThread.main(ActivityThread.java:5419)
04-11 18:59:55.930:E / AndroidRuntime(2023):在java.lang.reflect.Method.invokeNative(本机方法)
04-11 18:59:55.930:E / AndroidRuntime(2023):在java.lang.reflect.Method.invoke(Method.java:525)
04-11 18:59:55.930:E / AndroidRuntime(2023):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1209)
04-11 18:59:55.930:E / AndroidRuntime(2023):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1025)
04-11 18:59:55.930:E / AndroidRuntime(2023):在dalvik.system.NativeStart.main(本机方法)
04-11 18:59:55.930:E / AndroidRuntime(2023):因:java.lang.reflect.InvocationTargetException
04-11 18:59:55.930:E / AndroidRuntime(2023):在java.lang.reflect.Constructor.constructNative(本机方法)
04-11 18:59:55.930:E / AndroidRuntime(2023):在java.lang.reflect.Constructor.newInstance(Constructor.java:417)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.view.LayoutInflater.createView(LayoutInflater.java:600)
04-11 18:59:55.930:E / AndroidRuntime(2023):45 ...更多
04-11 18:59:55.930:E / AndroidRuntime(2023):android.content.res.Resources $ NotFoundException:由造成资源不是ColorStateList(彩色或路径):{的TypedValue T =为0x1 / D = 0x7f060006一个= -1 R = 0x7f060006}
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.content.res.Resources.loadColorStateList(Resources.java:3115)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.content.res.TypedArray.getColorStateList(TypedArray.java:343)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.widget.TextView<&初始化GT;(TextView.java:1232)
04-11 18:59:55.930:E / AndroidRuntime(2023):在android.widget.TextView<&初始化GT;(TextView.java:876)
04-11 18:59:55.930:E / AndroidRuntime(2023):48 ...更多
问题是与你的布局。您正在设置的样式以文字颜色
机器人:文字颜色=@风格/ RText
您需要设置的颜色 不是风格
更改为
机器人:文字颜色=@彩色/ RText
请确保您有color.xml为RText颜色值
Does anyone see why my app crashes when I try to load this page with a ListView?
Probably an easy fix but I'm new and not sure whats wrong!
Trying to repeat scorecard_row in a listview, then using an ArrayAdapter populate each row with text 1-18, should be easy! But when I run the app and click on the page it crashes!
If I change this line:
ArrayAdapter adapter = new ArrayAdapter<String>(this, R.layout.scorecard_row, R.id.txtHoleNum, values);
to
ArrayAdapter adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, values);
it will successfully display the stock android list item with incrementing numbers.
ANY help is greatly appreciated, literally stuck on this for 5+ hours
PlayActivity:
import java.io.IOException;
import java.util.ArrayList;
import android.app.Activity;
import android.app.ActionBar;
import android.app.Fragment;
import android.database.SQLException;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.os.Build;
public class PlayActivity extends Activity {
private ListView listview;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_play);
//get listview object from xml
listview = (ListView) findViewById(R.id.listviewSC);
String[] values = new String[] {"1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18"};
//String[] parValues;
//ScorecardAdapter adapter = new ScorecardAdapter(this, values);
ArrayAdapter adapter = new ArrayAdapter<String>(this, R.layout.scorecard_row, R.id.txtHoleNum, values);
//assign adapter to listview
listview.setAdapter(adapter);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.play, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
public void onSave(){
DataBaseHelper myDbHelper;
myDbHelper = new DataBaseHelper(this);
try {
myDbHelper.createDataBase();
} catch (IOException ioe) {
throw new Error("Unable to create database");
}
try {
myDbHelper.openDataBase();
}catch(SQLException sqle){
throw sqle;
}
}
}
scorecard_row.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" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="17dp"
android:text="Hole"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/txtHoleNum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/textView1"
android:text="12"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@style/RText" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView1"
android:layout_alignBottom="@+id/textView1"
android:layout_marginLeft="15dp"
android:layout_toRightOf="@+id/textView1"
android:text="Par"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/txtPar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/txtHoleNum"
android:layout_alignBottom="@+id/txtHoleNum"
android:layout_alignLeft="@+id/textView2"
android:text="4"
android:textAppearance="?android:attr/textAppearanceLarge" />
<CheckBox
android:id="@+id/cbGIR"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView2"
android:layout_alignBottom="@+id/textView2"
android:layout_marginLeft="18dp"
android:layout_toRightOf="@+id/textView2"
android:text="GIR" />
<CheckBox
android:id="@+id/cbFW"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/cbGIR"
android:layout_below="@+id/cbGIR"
android:text="FW" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/textView2"
android:layout_marginLeft="22dp"
android:layout_toRightOf="@+id/cbGIR"
android:text="Putts"
android:textAppearance="?android:attr/textAppearanceSmall" />
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView3"
android:layout_below="@+id/textView4"
android:ems="3"
android:inputType="number"
android:maxEms="3" />
<EditText
android:id="@+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/editText1"
android:layout_alignBottom="@+id/editText1"
android:layout_alignParentRight="true"
android:ems="3"
android:inputType="number"
android:maxEms="3" >
<requestFocus />
</EditText>
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView3"
android:layout_alignBottom="@+id/textView3"
android:layout_alignParentRight="true"
android:text="Score"
android:textAppearance="?android:attr/textAppearanceLarge" />
</RelativeLayout>
EDIT:LogCat stacktrace
04-11 18:59:55.900: D/AbsListView(2023): Get MotionRecognitionManager
04-11 18:59:55.905: D/AbsListView(2023): onVisibilityChanged() is called, visibility : 4
04-11 18:59:55.905: D/AbsListView(2023): unregisterIRListener() is called
04-11 18:59:55.910: D/AbsListView(2023): onVisibilityChanged() is called, visibility : 0
04-11 18:59:55.910: D/AbsListView(2023): unregisterIRListener() is called
04-11 18:59:55.920: D/AndroidRuntime(2023): Shutting down VM
04-11 18:59:55.920: W/dalvikvm(2023): threadid=1: thread exiting with uncaught exception (group=0x41caa700)
04-11 18:59:55.930: E/AndroidRuntime(2023): FATAL EXCEPTION: main
04-11 18:59:55.930: E/AndroidRuntime(2023): android.view.InflateException: Binary XML file line #16: Error inflating class <unknown>
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.view.LayoutInflater.createView(LayoutInflater.java:626)
04-11 18:59:55.930: E/AndroidRuntime(2023): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:675)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:700)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:371)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.widget.ArrayAdapter.getView(ArrayAdapter.java:362)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.widget.AbsListView.obtainView(AbsListView.java:2627)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.widget.ListView.measureHeightOfChildren(ListView.java:1259)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.widget.ListView.onMeasure(ListView.java:1171)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.view.View.measure(View.java:16831)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5245)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1410)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.view.View.measure(View.java:16831)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5245)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.view.View.measure(View.java:16831)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5245)
04-11 18:59:55.930: E/AndroidRuntime(2023): at com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:302)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.view.View.measure(View.java:16831)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5245)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
04-11 18:59:55.930: E/AndroidRuntime(2023): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2586)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.view.View.measure(View.java:16831)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2189)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1352)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1535)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1249)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6364)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:791)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.view.Choreographer.doCallbacks(Choreographer.java:591)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.view.Choreographer.doFrame(Choreographer.java:561)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:777)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.os.Handler.handleCallback(Handler.java:730)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.os.Handler.dispatchMessage(Handler.java:92)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.os.Looper.loop(Looper.java:137)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.app.ActivityThread.main(ActivityThread.java:5419)
04-11 18:59:55.930: E/AndroidRuntime(2023): at java.lang.reflect.Method.invokeNative(Native Method)
04-11 18:59:55.930: E/AndroidRuntime(2023): at java.lang.reflect.Method.invoke(Method.java:525)
04-11 18:59:55.930: E/AndroidRuntime(2023): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1209)
04-11 18:59:55.930: E/AndroidRuntime(2023): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1025)
04-11 18:59:55.930: E/AndroidRuntime(2023): at dalvik.system.NativeStart.main(Native Method)
04-11 18:59:55.930: E/AndroidRuntime(2023): Caused by: java.lang.reflect.InvocationTargetException
04-11 18:59:55.930: E/AndroidRuntime(2023): at java.lang.reflect.Constructor.constructNative(Native Method)
04-11 18:59:55.930: E/AndroidRuntime(2023): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.view.LayoutInflater.createView(LayoutInflater.java:600)
04-11 18:59:55.930: E/AndroidRuntime(2023): ... 45 more
04-11 18:59:55.930: E/AndroidRuntime(2023): Caused by: android.content.res.Resources$NotFoundException: Resource is not a ColorStateList (color or path): TypedValue{t=0x1/d=0x7f060006 a=-1 r=0x7f060006}
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.content.res.Resources.loadColorStateList(Resources.java:3115)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.content.res.TypedArray.getColorStateList(TypedArray.java:343)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.widget.TextView.<init>(TextView.java:1232)
04-11 18:59:55.930: E/AndroidRuntime(2023): at android.widget.TextView.<init>(TextView.java:876)
04-11 18:59:55.930: E/AndroidRuntime(2023): ... 48 more
Issue is with your layout. Your are setting a style to textColor
android:textColor="@style/RText"
You need to set a color , not style
change this to
android:textColor="@color/RText"
Make sure you have color value for RText in color.xml
这篇关于ListView控件不能正常工作的android - 自定义视图,ArrayAdapter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!