2016-10-03 23 views
0

以下のコードでは、moneytipボタンをクリックすると、edittext経由でalertdialogのテーブルに値を追加しようとしています。それらのsoftkeypadはup.Iは、すべてのソリューションを試みたが、何もソフトキーパッドがカスタムAlertDialogBox内にポップアップ表示されない

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

        LayoutInflater inflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
        View view1 = inflater.inflate(R.layout.record_in_new, null); 
        alertDialogBuilder.setView(view1); 

        TextView cust_txt=(TextView)view1.findViewById(R.id.title); 
        cust_txt.setText((R.string.record)); 
        final AlertDialog alertDialog = alertDialogBuilder.create(); 

        final View view2=view1; 

        alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); 
        alertDialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE); 
        alertDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN); 
        alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); 
        alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); 
        alertDialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); 

        alertDialog.show(); 

        alertDialog.findViewById(R.id.deposit_money).setOnClickListener(new View.OnClickListener() 
        { 
         EditText myEditDate = new EditText(view2.getContext()); 
         EditText myEditAmount = new EditText(view2.getContext()); 

         @Override 

         public void onClick(View v) { 

         LinearLayout.LayoutParams param = new TableRow.LayoutParams(
            TableRow.LayoutParams.MATCH_PARENT, 
            TableRow.LayoutParams.MATCH_PARENT, 1.0f); 

          LinearLayout mLinear = (LinearLayout) view2.findViewById(R.id.editlayout); 
          LinearLayout mtxt = (LinearLayout) view2.findViewById(R.id.textbar); 
          LinearLayout medit = (LinearLayout) view2.findViewById(R.id.editboxes); 
          LinearLayout ldate = (LinearLayout) view2.findViewById(R.id.date); 
          LinearLayout lamount = (LinearLayout) view2.findViewById(R.id.amount); 
          LinearLayout lbutton = (LinearLayout) view2.findViewById(R.id.buttonlayout); 
          LinearLayout mbt1 = (LinearLayout) view2.findViewById(R.id.bt1); 
          LinearLayout mbt2 = (LinearLayout) view2.findViewById(R.id.bt2); 
          LinearLayout.LayoutParams mRparams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT); 



          medit.setWeightSum(2); 

          TextView title = new TextView(view2.getContext()); 
          title.setText("Enter Deposit Date and Amount"); 
          mtxt.addView(title); 
          TextView date = new TextView(view2.getContext()); 
          date.setText("Date"); 
          ldate.setLayoutParams(param); 
          ldate.setGravity(View.TEXT_ALIGNMENT_CENTER); 
          ldate.addView(date); 
          ldate.addView(myEditDate); 

          TextView amount = new TextView(view2.getContext()); 
          amount.setText("Amount"); 
          lamount.setLayoutParams(param); 
          lamount.setGravity(View.TEXT_ALIGNMENT_CENTER); 
          lamount.addView(amount); 
          myEditDate.setOnFocusChangeListener(new View.OnFocusChangeListener() { 
           @Override 
           public void onFocusChange(View v, boolean hasFocus) { 
            if (hasFocus) { 
             alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); 
            } 
           } 
          }); 
          myEditDate.setOnKeyListener(new View.OnKeyListener() { 
           @Override 
           public boolean onKey(View v, int keyCode, KeyEvent event) { 
            String tmp = myEditDate.getText().toString(); 
            if (keyCode == KeyEvent.KEYCODE_DEL) { 

             myEditDate.setText(""); 


            } 
            return false; 
           } 
          }); 
          lamount.addView(myEditAmount); 

         } 

答えて

0

を働いていないあなたはXMLでEditTextsのために、「<のrequestFocus />」を入れましたポップされていませんか?

+0

プログラムで編集テキストを追加する –

+0

edittext.requestFocus(); – DroidDev

+0

フォーカスが上がっていますが、キーパッドがポップアップしません –

関連する問題