2016-07-11 2 views
0

私はいくつかの静的データでRadarChartを動作させることができます。今私は、ユーザーがいくつかのデータを入力して、この入力データを使用してグラフを再描画するように頼むために、ユーザーがradarchartをクリックすると警告ダイアログを表示したい。MPAndrioid RadarChartからAlertDialogを呼び出す

私はMarkerViewを拡張するMyMarkerViewクラスを作成しました。また、refreshContentメソッドでは、Alert Dialogビューのコードを追加しました。

しかし、問題は、AlerDialogをクリックするたびにrefreshContentが再び呼び出され、新しい警告ダイアログが作成され、ユーザーは何も入力できないということです。以下 はrefreshContent法の下

 LayoutInflater li = LayoutInflater.from(mContext); 
      View promptsView = li.inflate(R.layout.month_target_analysis_dialog, null); 

      AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(mContext); 

      // set prompts.xml to alertdialog builder 
      alertDialogBuilder.setView(promptsView); 

      final EditText userInput1 = (EditText) promptsView.findViewById(R.id.textView1Edit); 
      final EditText userInput2 = (EditText) promptsView.findViewById(R.id.textView2Edit); 

      // set dialog message 
      alertDialogBuilder.setCancelable(false); 
      alertDialogBuilder.setPositiveButton("OK", 
        new DialogInterface.OnClickListener() { 
         public void onClick(DialogInterface dialog, int id) { 
          // get user input and set it to result 
          // edit text 
          //result.setText(userInput.getText()); 
          String input1 = userInput1.getText().toString(); 
          String input2 = userInput1.getText().toString(); 
          if (userInput1.getError() == null && userInput2.getError() == null) { 
           //Do something 
          } else { 
          } 
         } 
        }); 
      alertDialogBuilder.setNegativeButton("Cancel", 
        new DialogInterface.OnClickListener() { 
         public void onClick(DialogInterface dialog, int id) { 
          dialog.cancel(); 
         } 
        }); 

      // create alert dialog 
      AlertDialog alertDialog = alertDialogBuilder.create(); 

      // show it 
      alertDialog.show(); 
     } 

のコードは、XMLレイアウト

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/layout_root" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" 
    android:padding="10dp" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 
     <TextView 
      android:id="@+id/textView1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:paddingRight="10dp" 
      android:text="@string/l_target" 
      android:textAppearance="@style/ItemMedium" /> 

     <EditText 
      android:id="@+id/textView1Edit" 
      android:layout_width="50dp" 
      android:layout_height="wrap_content" 
      android:paddingLeft="50dp" 
      android:clickable="false" 
      android:inputType="number" 
      > 
      <requestFocus /> 
     </EditText> 
    </LinearLayout> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 
     <TextView 
      android:id="@+id/textView2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:paddingRight="10dp" 
      android:text="@string/g_target" 
      android:textAppearance="@style/ItemMedium" /> 

     <EditText 
      android:id="@+id/textView2Edit" 
      android:layout_width="50dp" 
      android:layout_height="wrap_content" 
      android:paddingLeft="50dp" 
      android:clickable="false" 
      android:inputType="number" 
      > 
     </EditText> 
    </LinearLayout> 

任意のアイデアをどのようにrefreshContentの呼び出しを無効にすることであるのですか? これを処理する他の方法がありますか?

おかげ Praveenさん

答えて

0

私はそれがMarkerViewを使用して動作させることができませんでした。代わりに、私はsetOnChartGestureListenerを定義して、チャート上のすべての可能なアクションを捕捉し、アクションが捕捉されたときに必要なアクションを処理しました。 働いているようです。

mChart.setOnChartGestureListener(new OnChartGestureListener() { 
     @Override 
      public void onChartSingleTapped(MotionEvent me) { 
       // TODO Auto-generated method stub 
       Log.e(LOG_TAG, "single tap"); 

      } 
      @Override 
      public void onChartDoubleTapped(MotionEvent me) { 
       // TODO Auto-generated method stub 
       Log.e(LOG_TAG, "double tap"); 
      } 
} 

おかげ

関連する問題