1

私はこの例を理解していません。私のプログラムに応募する方法

私は自分のプログラムに書き込もうとしています

私ができる一般的な使用。しかし、フラグメントを置き換えました。使い方がわかりません。

オブジェクトの値を渡します。

    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        super.onCreateView(inflater, container, savedInstanceState);
        View view = inflater.inflate(R.layout.templistmune, container, false);
FragmentManager DS2 = getFragmentManager();
    FragmentTransaction DSE2 = DS2.beginTransaction();
    Fragment DF2 = DS2.findFragmentById(R.id.frameLayout4);
    if (DF2 == null) {
        String title = "Fragment A";
        templistview2 usermune = new templistview2(title);
        DSE2.add(R.id.frameLayout4, usermune);
        DSE2.addToBackStack(null);
        DSE2.commit();   
/////////////////////////////////////////////////////////   
        Bundle bundle = new Bundle();
        String SAS="50";
        bundle.putString("ST", SAS);
        DF2.setArguments(bundle);
////////////////////////////////////////////////
        }

オブジェクトtemplistview2.javaのピック値

    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        super.onCreateView(inflater, container, savedInstanceState);
        View view = inflater.inflate(R.layout.templistmune2, container, false);
////////////////////////////////////////////////////////////////////////////////////
     Bundle bundle = this.getArguments();
    String myST = bundle.getString("ST", SAS);
 ///////////////////Error SAS cannot be resolved to a variable  /////////////////



        return view;

    }
4

1 に答える 1

1

Bundlewhen nullを追加するだけです...そのため、プログラムは行のどこDF2かでクラッシュするか、実行されますが合格しません。NullPointerExceptionBundle

だから場所

    Bundle bundle = new Bundle();
    String SAS="50";
    bundle.putString("ST", SAS);
    DF2.setArguments(bundle);

if構造の外側。

于 2012-11-29T22:13:40.157 に答える