错误日志:
android.content.res.Resources$NotFoundException: String resource ID #0x0
at android.content.res.Resources.getText(Resources.java:299)
at android.widget.TextView.setText(TextView.java:4138)
at me.axiom.aapp.ironbannercompanion.ListViewAdapter.getView(ListViewAdapter.java:43)
at android.widget.AbsListView.obtainView(AbsListView.java:2347)
at android.widget.ListView.measureHeightOfChildren(ListView.java:1270)
at android.widget.ListView.onMeasure(ListView.java:1182)
at android.view.View.measure(View.java:17565)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:727)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:463)
at android.view.View.measure(View.java:17565)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5537)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135)
at android.view.View.measure(View.java:17565)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5537)
at android.support.v7.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:391)
at android.view.View.measure(View.java:17565)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5537)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
at android.view.View.measure(View.java:17565)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5537)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
at android.view.View.measure(View.java:17565)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5537)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2615)
at android.view.View.measure(View.java:17565)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2045)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1196)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1409)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1084)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5990)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
at android.view.Choreographer.doCallbacks(Choreographer.java:580)
at android.view.Choreographer.doFrame(Choreographer.java:550)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5343)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
ListViewAdapter类:
String url="http://bungie.net";
private Context context;
private GuardianInfo[] guardianList;
private LayoutInflater inflater;
public ListViewAdapter(Context context, int resource, GuardianInfo[] object) {
super(context, resource, object);
this.context = context;
this.guardianList = object;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (inflater == null)
inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (convertView == null)
convertView = inflater.inflate(R.layout.listview_characters_content, parent, false);
GuardianInfo guardian = guardianList[position];
TextView textView_Class = (TextView) convertView.findViewById(R.id.listView_CLASS);
textView_Class.setText(guardian.getCharacterBase().getClassType());
ImageView imageView_IMG = (ImageView) convertView.findViewById(R.id.listView_IMG);
ImageView imageView_BG = (ImageView) convertView.findViewById(R.id.listView_BG);
Picasso.with(context).load(url + guardian.getEmblemPath()).into(imageView_IMG);
Picasso.with(context).load(url + guardian.getBackgroundPath()).into(imageView_BG);
return convertView;
}
现在,当我尝试更改textView_Class的文本时,似乎发生了错误。它说资源无法找到。
我也是通过
设置ListAdapterGuardianInfo[] guardians = response.body().getResponse().getData().getCharacters();
ListViewAdapter adapter = new ListViewAdapter(getBaseContext(), R.layout.listview_characters_content, guardians);
ListView listView_Characters = (ListView) findViewById(R.id.listView_Characters);
listView_Characters.setAdapter(adapter);
答案 0 :(得分:1)
从Exception中,您看起来正在为TextView设置一些int值。在为TextView设置int值时,它会认为您正在尝试使用ID等于int值的String资源设置文本,在您的情况下可能是guardian.getCharacterBase().getClassType()
。尝试替换此行
textView_Class.setText(guardian.getCharacterBase().getClassType());
用这个
textView_Class.setText(String.valueOf(guardian.getCharacterBase().getClassType()));
答案 1 :(得分:0)
显示您的列表项目布局... R.layout.listview_characters_content