0

フラグメントから Web ビューを開こうとしています。webview は新しいアクティビティです。これまでに見たことのないエラーが発生し続けており、それを理解するのに実際に役立つ可能性があります.

webview アクティビティを起動するフラグメントは次のとおりです。

public class TextFragment extends Fragment {

    private FuzzAdapter mAdapter;
    private ArrayList<Fuzzy> mFuzzies;
    public final String TAG = MainActivity.class.getSimpleName();

    public static TextFragment newInstance(ArrayList<Fuzzy> fuzzies) {
        TextFragment fragment = new TextFragment();
        Bundle bundle = new Bundle();
        bundle.putSerializable("fuzzies", fuzzies);
        fragment.setArguments(bundle);
        return fragment;
    }

    @SuppressWarnings("unchecked")
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        ArrayList<Fuzzy> textArray = new ArrayList<Fuzzy>();
        int textType;
        String textData = null;

        mFuzzies = (ArrayList<Fuzzy>) getArguments().getSerializable("fuzzies");
        for (int i = 0; i < mFuzzies.size(); i++) {
            Fuzzy fuzzy = mFuzzies.get(i);
            if (fuzzy.mType == 0) {
                textType = fuzzy.mType;
                textData = fuzzy.mData;

                Fuzzy textFuzzy = new Fuzzy(textData, textType);
                textArray.add(textFuzzy);   
            }
        }

        mAdapter = new FuzzAdapter(new ArrayList<Fuzzy>(), getActivity());
        mAdapter.setFuzzList(textArray);
        mAdapter.notifyDataSetChanged();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {

        View rootView = inflater.inflate(R.layout.text_layout, container, false);

        if (mFuzzies.isEmpty()) {
            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
            builder.setTitle(getString(R.string.title));
            builder.setMessage(getString(R.string.error_message));
            builder.setPositiveButton(android.R.string.ok, null);
            builder.show();
        }

        ListView listView = (ListView) rootView.findViewById(R.id.listView0);
        listView.setAdapter(mAdapter);      
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> adapterView, View view,
                    int position, long id) {

                Intent intent = new Intent(getActivity(),
                        FuzzWebViewActivity.class);
                intent.setData(Uri.parse("http://www.google.com/"));
                startActivity(intent);
            }
        });

        return rootView;
    }
}

Webview アクティビティは次のとおりです。

public class FuzzWebViewActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_fuzz_web_view);

        Intent intent = getIntent();
        Uri fuzzUri = intent.getData();

        WebView webView = (WebView) findViewById(R.id.webView1);
        webView.loadUrl(fuzzUri.toString());

    }
}

そして、ここにlogcatがあります:

10-21 18:01:34.386: E/AndroidRuntime(2984): FATAL EXCEPTION: main
10-21 18:01:34.386: E/AndroidRuntime(2984): java.lang.RuntimeException: Parcel: unable to marshal value com.petesesto.fuzztest.behind.Fuzzy@40dd94b8
10-21 18:01:34.386: E/AndroidRuntime(2984):     at android.os.Parcel.writeValue(Parcel.java:1235)
10-21 18:01:34.386: E/AndroidRuntime(2984):     at android.os.Parcel.writeList(Parcel.java:622)
10-21 18:01:34.386: E/AndroidRuntime(2984):     at android.os.Parcel.writeValue(Parcel.java:1195)
10-21 18:01:34.386: E/AndroidRuntime(2984):     at android.os.Parcel.writeMapInternal(Parcel.java:591)
10-21 18:01:34.386: E/AndroidRuntime(2984):     at android.os.Bundle.writeToParcel(Bundle.java:1627)
10-21 18:01:34.386: E/AndroidRuntime(2984):     at android.os.Parcel.writeBundle(Parcel.java:605)
10-21 18:01:34.386: E/AndroidRuntime(2984):     at android.support.v4.app.FragmentState.writeToParcel(Fragment.java:132)
10-21 18:01:34.386: E/AndroidRuntime(2984):     at android.os.Parcel.writeTypedArray(Parcel.java:1102)
10-21 18:01:34.386: E/AndroidRuntime(2984):     at android.support.v4.app.FragmentManagerState.writeToParcel(FragmentManager.java:368)
10-21 18:01:34.386: E/AndroidRuntime(2984):     at android.os.Parcel.writeParcelable(Parcel.java:1254)
10-21 18:01:34.386: E/AndroidRuntime(2984):     at android.os.Parcel.writeValue(Parcel.java:1173)
10-21 18:01:34.386: E/AndroidRuntime(2984):     at android.os.Parcel.writeMapInternal(Parcel.java:591)
10-21 18:01:34.386: E/AndroidRuntime(2984):     at android.os.Bundle.writeToParcel(Bundle.java:1627)
10-21 18:01:34.386: E/AndroidRuntime(2984):     at android.os.Parcel.writeBundle(Parcel.java:605)
10-21 18:01:34.386: E/AndroidRuntime(2984):     at android.app.ActivityManagerProxy.activityStopped(ActivityManagerNative.java:2252)
10-21 18:01:34.386: E/AndroidRuntime(2984):     at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3052)
10-21 18:01:34.386: E/AndroidRuntime(2984):     at android.os.Handler.handleCallback(Handler.java:725)
10-21 18:01:34.386: E/AndroidRuntime(2984):     at android.os.Handler.dispatchMessage(Handler.java:92)
10-21 18:01:34.386: E/AndroidRuntime(2984):     at android.os.Looper.loop(Looper.java:137)
10-21 18:01:34.386: E/AndroidRuntime(2984):     at android.app.ActivityThread.main(ActivityThread.java:5041)
10-21 18:01:34.386: E/AndroidRuntime(2984):     at java.lang.reflect.Method.invokeNative(Native Method)
10-21 18:01:34.386: E/AndroidRuntime(2984):     at java.lang.reflect.Method.invoke(Method.java:511)
10-21 18:01:34.386: E/AndroidRuntime(2984):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
10-21 18:01:34.386: E/AndroidRuntime(2984):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
10-21 18:01:34.386: E/AndroidRuntime(2984):     at dalvik.system.NativeStart.main(Native Method)
4

1 に答える 1

0

Fuzzy クラスに Serializable またはParcelableインターフェースを実装させる必要があります。それを行うのに助けが必要な場合は叫んでください;-)

于 2013-10-21T20:45:06.233 に答える