0

私はListViewに2つのTextViews(たとえばt1、t2)があり、ListViewはxmlによって作成されています。これはActivityで膨らんでいます。
私の条件は、ユーザーがListViewアイテムをクリックすると、新しいアクティビティが表示されます。また、アイテムをクリックすると、t2が表示され、別のアクティビティが開始されます。
しかし問題は、ListViewアイテムのいずれかをクリックしても機能していないということです。どちらの場合でも同じActivityに移動します。インテントがアクティビティの呼び出しでリダイレクトされないのはなぜですか?

私のコード(のように - getViewメソッド()メソッド内):

mylayout.setOnClickListener(new OnClickListener() { 
      public void onClick(View v) { 
       try { 
        if (listType == 1) { 
         Log.v("active", "On Click " + (position)); 
         Intent intent = new Intent(VoucherActiveScreen.this,MyVoucherDetailPage.class); 
         intent.putExtra("selectedIndex", position); 
         intent.putExtra("listType", listType); 
         startActivity(intent); 
        } 
        else if (listType == 3) { 
           //String str = offerPrice.getText().toString(); 
           //System.out.println(str); 
           if (voucherOffer.getIs_redeem().toString().equals("1")) 
           { 
            System.out.println(voucherOffer.getIs_redeem().toString()+"if Rate"); //its working when click listview which contains Rate 

            Intent intratedeal=new Intent(getBaseContext(),RateDeal.class); 
            intratedeal.setClass(getBaseContext(), RateDeal.class); 
            startActivityForResult(intratedeal, 1); 
           } 
           else 
            { 
            System.out.println(voucherOffer.getIs_redeem().toString()+"else View"); //its working when click listview which contains View 
            Intent intratevendor=new Intent(getBaseContext(),RateVendor.class); 
            //intratevendor.setClass(getBaseContext(), RateVendor.class); 
             startActivityForResult(intratevendor, 1); 
            } 
          /*Intent intent = new Intent(
             VoucherActiveScreen.this, 
             MyVoucherDetailPage.class); 
           intent.putExtra("listType", listType); 
           intent.putExtra("selectedIndex", position);*/ 
           Log.v("inactiveeeeeeeeeeeeeeeeee", "On Click " + (position)); 

           //startActivity(intent); 

        } 
       } catch (Exception e) { 
        // TODO: handle exception 
       } 
      } 
     }); 

してくださいいずれかの助けのブロックが、目的は同じ活動に

+0

あなたが任意のエラーや例外を取得しているの??そのエラーをここに書いてください... –

+0

エラーはありません。問題はリダイレクトされません。正しいブロックを検出している間、if-elseブロックに記載されている必要なアクティビティ – sandee

答えて

0

をリダイレクトされていない場合は、他の... コントロールがうまくいっています

Intent intent = new Intent(VoucherActiveScreen.this,MyVoucherDetailPage.class); 
intent.putExtra("selectedIndex", position); 
intent.putExtra("listType", listType); 
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
startActivity(intent); 

上記のスニペットで新しいアクティビティタスクが開始されます。このリンクを参照してください:

http://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_NEW_TASK

関連する問題