我的應用程序似乎在某些使用較舊Android操作系統的設備上沒有任何正當理由而崩潰,並且在所有其他設備上運行良好。使用Android的某些設備上的getView(未知源)2.3.4-2.3.6
@Override
public View getView(int position, View convertView, ViewGroup viewGroup) {
LayoutInflater vi;
View v = convertView;
if (v == null) {
vi = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.general_contact_item_layout, null, false);
ViewHolder holder = new ViewHolder();
holder.imageView = (ImageView) v.findViewById(R.id.contactImage);
holder.txtName = (TextView) v.findViewById(R.id.contactName);
holder.txtName.setTextSize(18);
v.setTag(holder);
}
final Contact contact = contacts.get(position);
if (contact != null) {
if (contact.contactID != null)
v.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, String.valueOf(contact.contactID));
intent.setData(uri);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
});
ViewHolder holder = (ViewHolder) v.getTag();
if (contact.name != null && contact.name.length() > 0)
holder.txtName.setText(contact.name);
else
holder.txtName.setText("(No Name)");
holder.imageView.setImageURI(null);
if (contact.photoUri != null)
holder.imageView.setImageURI(contact.photoUri);
}
return v;
}
這裏是我的ArrayAdapter堆棧跟蹤:
java.lang.NullPointerException
at de.android.cc.clean.ui.a.getView(Unknown Source)
at android.widget.AbsListView.obtainView(AbsListView.java:1539)
at android.widget.ListView.makeAndAddView(ListView.java:1794)
at android.widget.ListView.fillDown(ListView.java:719)
at android.widget.ListView.fillSpecific(ListView.java:1351)
at android.widget.ListView.layoutChildren(ListView.java:1625)
at android.widget.AbsListView.onLayout(AbsListView.java:1390)
at android.view.View.layout(View.java:7228)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
at android.view.View.layout(View.java:7228)
at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
at android.view.View.layout(View.java:7228)
at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
at android.view.View.layout(View.java:7228)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
at android.view.View.layout(View.java:7228)
at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
at android.view.View.layout(View.java:7228)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
at android.view.View.layout(View.java:7228)
at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
at android.view.View.layout(View.java:7228)
at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
at android.view.View.layout(View.java:7228)
at android.view.ViewRoot.performTraversals(ViewRoot.java:1145)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1865)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3687)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
的問題是,這個錯誤似乎有it's源別處。
受影響的設備,例如:
- ONE TOUCH 4007D
- GT-I9070
- GT-S5360
- GT-I9000
有沒有導致任何已知的問題這個問題?
該代碼似乎被混淆並且調試信息被刪除。但它仍然是你的'getView()'NPE所在的地方。 – laalto
是的,這是混淆 –