検索ボタンがあります。
クリックすると、現在のアクティビティから他のアクティビティ (私の場合は ProductActivity) に値を送信したい
検索ボタンのコードはこちら
Button nextActivity = (Button) findViewById(R.id.btnSearch);
nextActivity.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
TextView tvFileNumber = (TextView)findViewById(R.id.tv1);
Spinner spAttachement = (Spinner)findViewById(R.id.spinner1) ;
Spinner spExecution = (Spinner)findViewById(R.id.spinner2) ;
Spinner spCategory = (Spinner)findViewById(R.id.spinner3) ;
Spinner spOperation = (Spinner)findViewById(R.id.spinner4) ;
Spinner spCollection = (Spinner)findViewById(R.id.spinner5) ;
SpinnerData daAttachement =(SpinnerData)spAttachement.getItemAtPosition(spAttachement.getSelectedItemPosition());
SpinnerData daExecution =(SpinnerData)spAttachement.getItemAtPosition(spExecution.getSelectedItemPosition());
SpinnerData daCategory =(SpinnerData)spAttachement.getItemAtPosition(spCategory.getSelectedItemPosition());
SpinnerData daOperation =(SpinnerData)spAttachement.getItemAtPosition(spOperation.getSelectedItemPosition());
SpinnerData daCollection =(SpinnerData)spAttachement.getItemAtPosition(spCollection.getSelectedItemPosition());
Intent myIntent = new Intent(view.getContext(), ProductActivity.class);
//myIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
myIntent.putExtra("col_id",6);
myIntent.putExtra("site_id",site_id);
myIntent.putExtra("brand_id",brand_id);
myIntent.putExtra("attachement_id",daAttachement.getValue());
myIntent.putExtra("execution_id",daExecution.getValue());
myIntent.putExtra("operation_id",daOperation.getValue());
myIntent.putExtra("category_id",daCategory.getValue());
startActivity(myIntent);
}
});
IN MY 製品活動
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_product);
Intent myIntent= getIntent();
int brand_id = myIntent.getIntExtra("brand_id", 0);
int col_id = myIntent.getIntExtra("col_id", 0);
int site_id = myIntent.getIntExtra("site_id", 0);
int attachement_id = myIntent.getIntExtra("attachement_id", -1);
int execution_id = myIntent.getIntExtra("execution_id", -1);
int category_id = myIntent.getIntExtra("category_id", -1);
int operation_id = myIntent.getIntExtra("operation_id", -1);
int eol = myIntent.getIntExtra("eol", -1);
Log.v("TESTCOLLECTION",Integer.toString(col_id));
THE RESULT
TESTCOLLECTION : 0 を示すログ結果
私の例では、それは 6 であると仮定しますmyIntent.putExtra("col_id",6);
助けてください。私は非常に多くのことを試しましたが、理由が見つかりませんでした。
どうもありがとう。