Ich kann das RadarChart mit einigen statischen Daten arbeiten. Jetzt möchte ich einen Alarmdialog anzeigen, wenn Benutzer auf das Radarchart klicken, um den Benutzer zu bitten, einige Daten einzugeben, und dann diese Eingabedaten verwenden, um das Diagramm neu zu zeichnen.Aufruf von AlertDialog von MPAndioid RadarChart
Ich habe eine MyMarkerView-Klasse erstellt, die MarkerView erweitert und in der refreshContent-Methode den Code für die Alert-Dialogansicht hinzufügt.
Aber das Problem ist, dass, wann immer verwendet, klicken Sie auf den AlerDialog, der refreshContent wird erneut aufgerufen und ein neues Alarmdialogfeld wird erstellt - und der Benutzer kann nichts eingeben. Unten ist der Code in der refreshContent Methode
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();
}
Unterhalb der XML-Layout ist
<?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>
Irgendwelche Ideen, wie die Berufung von refreshContent zu deaktivieren? Oder gibt es einen anderen besseren Weg, dies zu behandeln?
Dank Praveen