سؤال

أنا النامية على الروبوت 2.2 باستخدام جافا.لقد وضعت editText على PopupWindow و هو لا يعمل.أنه يتصرف مثل تعطيل تحرير النص بالضغط على تحرير النص لن تظهر لوحة المفاتيح لينة.كيف يمكنني إضافة تحرير النص على popupWindow?

هل كانت مفيدة؟

المحلول 2

يجب حل مثل هذه المشكلة:أنا وضعت popupWindow.setFocusable(true); والآن هو يعمل.يبدو أن تحرير النص الذي كان على نافذة البوب لم يكن التركيز لأن نافذة منبثقة لم يكن التركيز.

نصائح أخرى

حاول فقط:

AlertDialog.Builder alert = new AlertDialog.Builder(this);

alert.setTitle("Title");
alert.setMessage("Message");

// Set an EditText view to get user input 
final EditText input = new EditText(this);
alert.setView(input);

alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {

  // Do something with value!
  }
});

alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
  public void onClick(DialogInterface dialog, int whichButton) {
    // Canceled.
  }
});

alert.show();

هل يحتوي EditText بالتأكيد على Android: خاصية قابلة للتحرير إلى True؟ إذا كان خطأ فسيتم تعطيله كما تصف.

popWindow.setFocusable(true);
popWindow.update();

سوف تعمل.

اتصل بهذا الرمز من أي مستمع

private void popUpEditText() {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("Comments");

        final EditText input = new EditText(this);
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.MATCH_PARENT);
        input.setLayoutParams(lp);
        builder.setView(input);

        // Set up the buttons
        builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {

             // do something here on OK 

            }
        });
        builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.cancel();
            }
        });
        builder.show();

    }
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top