我正在尝试从下面的片段类开始一个Activity。
List.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
ItemDetail Item = DetailItem.get(position - 1);
Intent intent = new Intent(getActivity(),
ComplateDetailActivity.class);
intent.putExtra("KEY", Item);
startActivity(intent);
}
});
编辑:
ItemDetail Class
@SuppressWarnings("serial")
public class ItemDetail implements Serializable {
public float ispoints;
public String fullDescription;
public ItemDetail() {
}
@SuppressLint("SimpleDateFormat")
public ItemDetail(ItemsDetail item , float rating , float ispoints)
{
this.ImageUrl = item.ImageUrl;
this.Name = item.Name;
this.UrlKey = item.UrlKey;
this.DateCreated = item.DateCreated;
try{ this.dateCreated = this.dateFormat.parse(item.DateCreated); } catch (Exception e){}
this.rating = rating;
this.ispoints = ispoints;
}
}
它在3.0以上的设备上工作正常但在2.3.6崩溃。请告诉我我在这里做错了什么我也试过getActivity.startActivity(intent);
。
下面是logcat完整输出
08-05 11:10:38.158: E/AndroidRuntime(21412): FATAL EXCEPTION: main
08-05 11:10:38.158: E/AndroidRuntime(21412): java.lang.IllegalArgumentException: no char field 'exponential'
08-05 11:10:38.158: E/AndroidRuntime(21412): at java.io.EmulatedFields.put(EmulatedFields.java:459)
08-05 11:10:38.158: E/AndroidRuntime(21412): at java.io.EmulatedFieldsForDumping.put(EmulatedFieldsForDumping.java:83)
08-05 11:10:38.158: E/AndroidRuntime(21412): at java.text.DecimalFormatSymbols.writeObject(DecimalFormatSymbols.java:591)
08-05 11:10:38.158: E/AndroidRuntime(21412): at java.lang.reflect.Method.invokeNative(Native Method)
08-05 11:10:38.158: E/AndroidRuntime(21412): at java.lang.reflect.Method.invoke(Method.java:507)
08-05 11:10:38.158: E/AndroidRuntime(21412): at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1219)
08-05 11:10:38.158: E/AndroidRuntime(21412): at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1575)
08-05 11:10:38.158: E/AndroidRuntime(21412): at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1847)
08-05 11:10:38.158: E/AndroidRuntime(21412): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1689)
08-05 11:10:38.158: E/AndroidRuntime(21412): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1653)
08-05 11:10:38.158: E/AndroidRuntime(21412): at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:1062)
08-05 11:10:38.158: E/AndroidRuntime(21412): at java.io.ObjectOutputStream.writeFields(ObjectOutputStream.java:1008)
08-05 11:10:38.158: E/AndroidRuntime(21412): at java.text.DecimalFormat.writeObject(DecimalFormat.java:1215)
08-05 11:10:38.158: E/AndroidRuntime(21412): at java.lang.reflect.Method.invokeNative(Native Method)
08-05 11:10:38.158: E/AndroidRuntime(21412): at java.lang.reflect.Method.invoke(Method.java:507)
08-05 11:10:38.158: E/AndroidRuntime(21412): at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1219)
08-05 11:10:38.158: E/AndroidRuntime(21412): at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1575)
08-05 11:10:38.158: E/AndroidRuntime(21412): at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1847)
08-05 11:10:38.158: E/AndroidRuntime(21412): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1689)
08-05 11:10:38.158: E/AndroidRuntime(21412): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1653)
08-05 11:10:38.158: E/AndroidRuntime(21412): at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:1143)
08-05 11:10:38.158: E/AndroidRuntime(21412): at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:413)
08-05 11:10:38.158: E/AndroidRuntime(21412): at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1241)
08-05 11:10:38.158: E/AndroidRuntime(21412): at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1205)
08-05 11:10:38.158: E/AndroidRuntime(21412): at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1575)
08-05 11:10:38.158: E/AndroidRuntime(21412): at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1847)
08-05 11:10:38.158: E/AndroidRuntime(21412): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1689)
08-05 11:10:38.158: E/AndroidRuntime(21412): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1653)
08-05 11:10:38.158: E/AndroidRuntime(21412): at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:1143)
08-05 11:10:38.158: E/AndroidRuntime(21412): at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:413)
08-05 11:10:38.158: E/AndroidRuntime(21412): at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1241)
08-05 11:10:38.158: E/AndroidRuntime(21412): at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1205)
08-05 11:10:38.158: E/AndroidRuntime(21412): at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1575)
08-05 11:10:38.158: E/AndroidRuntime(21412): at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1847)
08-05 11:10:38.158: E/AndroidRuntime(21412): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1689)
08-05 11:10:38.158: E/AndroidRuntime(21412): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1653)
08-05 11:10:38.158: E/AndroidRuntime(21412): at android.os.Parcel.writeSerializable(Parcel.java:1171)
08-05 11:10:38.158: E/AndroidRuntime(21412): at android.os.Parcel.writeValue(Parcel.java:1130)
08-05 11:10:38.158: E/AndroidRuntime(21412): at android.os.Parcel.writeMapInternal(Parcel.java:488)
08-05 11:10:38.158: E/AndroidRuntime(21412): at android.os.Bundle.writeToParcel(Bundle.java:1552)
08-05 11:10:38.158: E/AndroidRuntime(21412): at android.os.Parcel.writeBundle(Parcel.java:502)
08-05 11:10:38.158: E/AndroidRuntime(21412): at android.content.Intent.writeToParcel(Intent.java:5767)
08-05 11:10:38.158: E/AndroidRuntime(21412): at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1384)
08-05 11:10:38.158: E/AndroidRuntime(21412): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1510)
08-05 11:10:38.158: E/AndroidRuntime(21412): at android.app.Activity.startActivityForResult(Activity.java:2988)
08-05 11:10:38.158: E/AndroidRuntime(21412): at android.support.v4.app.FragmentActivity.startActivityFromFragment(FragmentActivity.java:833)
08-05 11:10:38.158: E/AndroidRuntime(21412): at android.support.v4.app.Fragment.startActivity(Fragment.java:856)
08-05 11:10:38.158: E/AndroidRuntime(21412): at com.codenterprise.left.fragment.shops.ShopsTopFragment$2.onItemClick(ShopsTopFragment.java:121)
08-05 11:10:38.158: E/AndroidRuntime(21412): at android.widget.AdapterView.performItemClick(AdapterView.java:284)
08-05 11:10:38.158: E/AndroidRuntime(21412): at android.widget.ListView.performItemClick(ListView.java:3569)
08-05 11:10:38.158: E/AndroidRuntime(21412): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1831)
08-05 11:10:38.158: E/AndroidRuntime(21412): at android.os.Handler.handleCallback(Handler.java:587)
08-05 11:10:38.158: E/AndroidRuntime(21412): at android.os.Handler.dispatchMessage(Handler.java:92)
08-05 11:10:38.158: E/AndroidRuntime(21412): at android.os.Looper.loop(Looper.java:150)
08-05 11:10:38.158: E/AndroidRuntime(21412): at android.app.ActivityThread.main(ActivityThread.java:4389)
08-05 11:10:38.158: E/AndroidRuntime(21412): at java.lang.reflect.Method.invokeNative(Native Method)
08-05 11:10:38.158: E/AndroidRuntime(21412): at java.lang.reflect.Method.invoke(Metho
EDITE 2:
这是ItemsDetail Class。
@SuppressWarnings("serial")
public class ItemsDetail implements Serializable {
public String Name;
public String ImageUrl;
public String DateCreated;
public Date dateCreated;
public DateFormat dateFormat;
public ItemsDetail() {
dateFormat = new SimpleDateFormat("dd-MM-yyyy");
}
public ItemsDetail(String title, String detail) {
this.Name = title;
this.Detail = detail;
}
}
答案 0 :(得分:0)
Android 2.3中存在DecimalFormatSymbols
序列化的错误。您可以看到说明here。如果您需要解决方法,请删除使用DecimalFormatSymbols
的字段(例如SimpleDateFormat
等)。
<强> UPD:强>
SimpleDateFormat dateFormat
字段声明为static final
。SimpleDateFormat dateFormat
字段并在构造函数中使用局部变量而不是此字段:
public ItemDetail(ItemsDetail item , float rating , float ispoints) {
this.ImageUrl = item.ImageUrl;
this.Name = item.Name;
this.UrlKey = item.UrlKey;
this.DateCreated = item.DateCreated;
SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy"); // change to your format
try {
this.dateCreated = format.parse(item.DateCreated);
} catch (Exception e) {
e.printStackTrace();
}
this.rating = rating;
this.ispoints = ispoints;
}
答案 1 :(得分:0)
这是Android错误,请参阅此https://code.google.com/p/android/issues/detail?id=14495