2016-03-22 2 views
1

私のクラスはFragmentから拡張されています。他のクラスにパラメータを追加したいと思います。 これを行うには、このコードを使用していました。Fragmentでintent.getExtras()を使用するには?

Intent intent = new Intent(getActivity(), AddContactActivity.class); 
Bundle b = new Bundle(); 
b.putString("numberPhone", phoneNumber); 
b.putString("timeStart", startTime); 
intent.getExtras(b); 
startActivity(intent); 

しかし、のようなこのショーのエラー:

error: method getExtras in class Intent cannot be applied to given types;

required: no arguments

found: Bundle

reason: actual and formal argument lists differ in length

+1

あなたはIntent.putExtra( "name"、b)を使用したい、getExtraを使用しない – Wukash

答えて

0

あなたが使用する必要がありますIntentにデータバンドルを設定したい場合は -

putExtras(Bundle bundle) 

のように -

Intent intent = new Intent(getActivity(), AddContactActivity.class); 
Bundle b = new Bundle(); 
b.putString("numberPhone", phoneNumber); 
b.putString("timeStart", startTime); 
intent.putExtras(b); 
startActivity(intent); 
+0

ありがとうございました。できます –

関連する問題