Binary XML file line #0: Attempt to invoke virtual method 'boolean java.lang.String.equals

头疼.......................

APP中需要实现LayoutInflater布局加载器动态加载布局,程序运行到该界面就闪退

之后查看日志一直提示我53行代码有问题,折腾了几天..........一直在activity界面该LayoutInflater语法,检查错误



结果:发现是个大坑!!!!!!!

最终错误出现在布局里:



有没有发现上面有什么不同????

问题就出在View上................View要大.大写..........

最终运行结果:


最后:感谢xxq2dream文章https://blog.csdn.net/myth13141314/article/details/79049882

Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null

03-30

各位大神,我想在tabhost里添加一个listview 然后出现了上面的错误 求解啊rn非常急,大白菜一个!rnrn[b]adapter.Java[/b]rnrnpackage com.zjz;rnrnimport java.util.List;rnimport java.util.Map;rnimport android.content.Context;rnimport android.view.LayoutInflater;rnimport android.view.View;rnimport android.view.ViewGroup;rnimport android.widget.BaseAdapter;rnimport android.widget.Button;rnimport android.widget.ImageView;rnimport android.widget.RatingBar;rnimport android.widget.TextView;rnrnpublic class Myadapter_2 extends BaseAdapterrn private Context context;rn private List> data;rn private LayoutInflater layoutInflater;rnrn public Myadapter_2(Context context,List> data)rn this.context=context;rn this.data=data;rn layoutInflater=LayoutInflater.from(context);rn rn rnrn @Overridern public int getCount() rn // TODO 自动生成的方法存根rn return data.size();rn rnrn @Overridern public Object getItem(int position) rn // TODO 自动生成的方法存根rn return data.get(position);rn rnrn @Overridern public long getItemId(int position) rn // TODO 自动生成的方法存根rn return position;rn rn rn static class Viewholderrn ImageView carte_image;rn TextView carte_name;rn RatingBar carte_scroe; rn TextView carte_monthlySales;rn Button carte_price;rn TextView scroe_rate2;rn rnrn @Overridern public View getView(int position, View convertView, ViewGroup parent) rn // TODO 自动生成的方法存根rn Viewholder holder;rn if(convertView==null)rn convertView=layoutInflater.inflate(R.layout.carte_list, null); rn holder=new Viewholder();rn holder.carte_image=(ImageView)convertViewrn .findViewById(R.id.carte_image);rn holder.carte_monthlySales=(TextView)convertViewrn .findViewById(R.id.carte_monthlySales);rn holder.carte_name=(TextView)convertViewrn .findViewById(R.id.carte_name);rn holder.carte_scroe=(RatingBar)convertViewrn .findViewById(R.id.carte_scroe);rn holder.carte_price=(Button)convertViewrn .findViewById(R.id.carte_price);rn holder.scroe_rate2=(TextView)convertViewrn .findViewById(R.id.score_rate2);rn convertView.setTag(holder);rn elsern holder=(Viewholder)convertView.getTag();rn rn rn rn View view=layoutInflater.inflate(R.layout.carte_list, null);rn rn ImageView carte_image=(ImageView)viewrn .findViewById(R.id.carte_image);rn TextView carte_name=(TextView)viewrn .findViewById(R.id.carte_name);rn RatingBar carte_scroe=(RatingBar)viewrn .findViewById(R.id.carte_scroe);rn TextView carte_monthlySales=(TextView)viewrn .findViewById(R.id.carte_monthlySales);rn Button carte_price=(Button)viewrn .findViewById(R.id.carte_price);rn TextView score_rate2=(TextView)viewrn .findViewById(R.id.score_rate2);rn rn Map carte_adapter=data.get(position);rn rn carte_image.setImageResource(rn (Integer) carte_adapter.get(Carte.KEY_1));rn carte_name.setText(rn (CharSequence)carte_adapter.get(Carte.KEY_2));rn carte_monthlySales.setText(rn (CharSequence)carte_adapter.get(Carte.KEY_3));rn carte_price.setText(rn (CharSequence)carte_adapter.get(Carte.KEY_4));rn score_rate2.setText(rn (CharSequence)carte_adapter.get(Carte.KEY_5));rn rn String str=(String)carte_adapter.get(Carte.KEY_5);rn carte_scroe.setRating(Float.parseFloat(str));rn rn return view;rn rnrnrnrnrnrn[b]Carte.java[/b]rnrnpackage com.zjz;rnrnimport java.util.ArrayList;rnimport java.util.HashMap;rnimport java.util.List;rnimport java.util.Map;rnrnrnrnimport android.app.Activity;rnrnimport android.os.Bundle;rnrnrnimport android.widget.ListView;rnimport android.widget.RatingBar;rnrnrnpublic class Carte extends Activityrn rn public static final String KEY_1="carte_image";rn public static final String KEY_2="carte_name";rn public static final String KEY_3="carte_monthlySales";rn public static final String KEY_4="carte_price";rn public static final String KEY_5="score_rate2";rn private RatingBar carte_scroe;rn private List> list;rnrn @Overridern protected void onCreate(Bundle savedInstanceState) rn // TODO 自动生成的方法存根rn super.onCreate(savedInstanceState);rn setContentView(R.layout.carte); rn rn rn getData();rn rn ListView carte_list=(ListView)this.findViewById(R.id.listView1);rn Myadapter adapter= new Myadapter(Carte.this, list);rn carte_list.setAdapter(adapter); rn rn rn private List> getData()rn list =new ArrayList>();rn for(int i=0;i<10;i++)rn Map carte_adapter=new HashMap();rn carte_adapter.put(KEY_1, R.drawable.ic_launcher);rn carte_adapter.put(KEY_2, "康师傅");rn carte_adapter.put(KEY_3, "月售"+i+"单");rn carte_adapter.put(KEY_4, i+"元");rn carte_adapter.put(KEY_5, i+"");rnrn list.add(carte_adapter);rn rn return list;rn rn rnrnrnrn[b]tabhost.java[/b]rnrnpackage com.zjz;rnrnrnimport android.app.TabActivity;rnimport android.content.Intent;rnimport android.os.Bundle;rnimport android.view.LayoutInflater;rnrnimport android.widget.TabHost;rnrnpublic class Restaurant_information extends TabActivityrn rn private TabHost tabhost;rn @Overridern protected void onCreate(Bundle savedInstanceState) rn // TODO 自动生成的方法存根rn super.onCreate(savedInstanceState);rnrn rn tabhost=this.getTabHost();rn LayoutInflater.from(this).inflate(R.layout.restaurant_information,rn tabhost.getTabContentView(),true);rn rn Intent itcarte=new Intent(this,Carte.class);rn Intent itintroduction_layout=new Intent(this,Restaurant_introduction.class); rn tabhost.addTab(tabhost.newTabSpec("tab1")rn .setIndicator("菜单")rn .setContent(itcarte));rn tabhost.addTab(tabhost.newTabSpec("tab2")rn .setIndicator("店铺信息")rn .setContent(itintroduction_layout)); rn rnrnrnrn错误显示:rnrn03-30 10:36:14.298: E/AndroidRuntime(1653): FATAL EXCEPTION: mainrn03-30 10:36:14.298: E/AndroidRuntime(1653): Process: com.zjz, PID: 1653rn03-30 10:36:14.298: E/AndroidRuntime(1653): java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object referencern03-30 10:36:14.298: E/AndroidRuntime(1653): at com.zjz.Myadapter.getView(Myadapter.java:111)rn03-30 10:36:14.298: E/AndroidRuntime(1653): at android.widget.AbsListView.obtainView(AbsListView.java:2347)rn03-30 10:36:14.298: E/AndroidRuntime(1653): at android.widget.ListView.measureHeightOfChildren(ListView.java:1270)rn03-30 10:36:14.298: E/AndroidRuntime(1653): at android.widget.ListView.onMeasure(ListView.java:1182)rn03-30 10:36:14.298: E/AndroidRuntime(1653): at android.view.View.measure(View.java:17547)rn03-30 10:36:14.298: E/AndroidRuntime(1653): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535)rn03-30 10:36:14.298: E/AndroidRuntime(1653): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)rn03-30 10:36:14.298: E/AndroidRuntime(1653): at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)rn03-30 10:36:14.298: E/AndroidRuntime(1653): at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)rn03-30 10:36:14.298: E/AndroidRuntime(1653): at android.view.View.measure(View.java:17547)rn03-30 10:36:14.298: E/AndroidRuntime(1653): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535)rn03-30 10:36:14.298: E/AndroidRuntime(1653): at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)rn03-30 10:36:14.298: E/AndroidRuntime(1653): at android.view.View.measure(View.java:17547)rn03-30 10:36:14.298: E/AndroidRuntime(1653): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535)rn03-30 10:36:14.298: E/AndroidRuntime(1653): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)rn03-30 10:36:14.298: E/AndroidRuntime(1653): at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)rn03-30 10:36:14.298: E/AndroidRuntime(1653): at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)rn03-30 10:36:14.298: E/AndroidRuntime(1653): at android.view.View.measure(View.java:17547)rn03-30 10:36:14.298: E/AndroidRuntime(1653): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535)rn03-30 10:36:14.298: E/AndroidRuntime(1653): at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)rn03-30 10:36:14.298: E/AndroidRuntime(1653): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2615)rn03-30 10:36:14.298: E/AndroidRuntime(1653): at android.view.View.measure(View.java:17547)rn03-30 10:36:14.298: E/AndroidRuntime(1653): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535)rn03-30 10:36:14.298: E/AndroidRuntime(1653): at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)rn03-30 10:36:14.298: E/AndroidRuntime(1653): at android.view.View.measure(View.java:17547)rn03-30 10:36:14.298: E/AndroidRuntime(1653): at android.widget.LinearLayout.measureVertical(LinearLayout.java:875)rn03-30 10:36:14.298: E/AndroidRuntime(1653): at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)rn03-30 10:36:14.298: E/AndroidRuntime(1653): at android.view.View.measure(View.java:17547)rn03-30 10:36:14.298: E/AndroidRuntime(1653): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535)rn03-30 10:36:14.298: E/AndroidRuntime(1653): at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)rn03-30 10:36:14.298: E/AndroidRuntime(1653): at android.view.View.measure(View.java:17547)rn03-30 10:36:14.298: E/AndroidRuntime(1653): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535)rn03-30 10:36:14.298: E/AndroidRuntime(1653): at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)rn03-30 10:36:14.298: E/AndroidRuntime(1653): at android.view.View.measure(View.java:17547)rn03-30 10:36:14.298: E/AndroidRuntime(1653): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535)rnrn

Binary XML file line #11: Error inflating class com.baidu.mapapi.map.MapView

08-11

按照官网配置出现以下问题rnandroid.view.InflateException: Binary XML file line #11: Error inflating class com.baidu.mapapi.map.MapViewrnrn这是java程序rnpackage com.example.map;rnrnimport com.baidu.mapapi.SDKInitializer;rnimport com.baidu.mapapi.map.MapView;rnrnimport android.support.v7.app.ActionBarActivity;rnimport android.app.Activity;rnimport android.os.Bundle;rnimport android.view.Menu;rnimport android.view.MenuItem;rnrnrnpublic class Map extends Activity rnrnMapView mMapView = null; rnrnrn@Overridernprotected void onCreate(Bundle savedInstanceState) rnrnsuper.onCreate(savedInstanceState);rnSDKInitializer.initialize(getApplicationContext());rnrnsetContentView(R.layout.activity_map);rnmMapView = (MapView) findViewById(R.id.bmapView);rnrn@Override rn protected void onDestroy() rn super.onDestroy(); rn //在activity执行onDestroy时执行mMapView.onDestroy(),实现地图生命周期管理 rn mMapView.onDestroy(); rn rn @Override rn protected void onResume() rn super.onResume(); rn //在activity执行onResume时执行mMapView. onResume (),实现地图生命周期管理 rn mMapView.onResume(); rn rn @Override rn protected void onPause() rn super.onPause(); rn //在activity执行onPause时执行mMapView. onPause (),实现地图生命周期管理 rn mMapView.onPause(); rn rnrnrnrn这是xml,红的是市第十一行rnrnrn rnrnrn试过网上很多方法都没解决,试过很多sdk版本都没解决rnrn[img=http://img.bbs.csdn.net/upload/201508/11/1439284793_375187.png][/img]rn要是这样配置文件不正确,求正确配置方法

没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试