2016-07-22 4 views
0

私は異なる製品イメージを表示できるアプリケーションを作成しています。それらを選択するボタンがあり、このボタンは情報をlocalhostに送信します。フラグメント内のEditTextからの入力を受け取ることができません

ただし、EditTextは機能しません。私がしている場合

ItemNote=(EditText) imageLayout.getActivity().findViewById(R.id.ItemNote); 

これは動作しますが、そのオプションだけで動作し、別のオプションで動作を停止します。

@Override 
    public Object instantiateItem(ViewGroup view, int position) { 
     View imageLayout = inflater.inflate(R.layout.item_pager_image, view, false); 
     assert imageLayout != null; 

     ImageView imageView = (ImageView) imageLayout.findViewById(R.id.image); 

     ItemNote=(EditText) imageLayout.findViewById(R.id.ItemNote); 
     ItemQuantity=(EditText)imageLayout.findViewById(R.id.ItemQuantity); 

     ItemName=(TextView) imageLayout.findViewById(R.id.ItemName); 
     ItemPrice=(TextView)imageLayout.findViewById(R.id.ItemPrice); 

     choose=(Button) imageLayout.findViewById(R.id.choose); 
      quantity=ItemQuantity.getText().toString(); 
      note=ItemNote.getText().toString(); 
      name=ItemName.getText().toString(); 
      price=ItemPrice.getText().toString(); 
     choose.setOnClickListener(new View.OnClickListener() { 

      public void onClick(View v) { 
       //getting input for item quantity and Item Extraa note 
       String Order= " "+name+" "+'('+quantity+')'+" With "+note+" Price : "+price+'\n'; 
       ItemNote.setText(""); // Reset the text field to blank 
       ItemQuantity.setText(""); // Reset the text field to blank 
       messsage = Order; // get the text message on the text field 
       SendMessage sendMessageTask = new SendMessage(); 
       sendMessageTask.execute(); 
      } 
     }); 

答えて

0

あなたはonClick内のノートを読む必要があります。現在、instantiateItemのテキストを読んでいるので、そのメソッドが呼び出されたときにのみテキストが取得されます。ボタンをクリックした時点でテキストを取得する必要があります。

関連する問題