Pertanyaan bisakah saya mendapatkan acara Edit teks cuti


saya ingin edittext "teks" untuk direfleksikan pada textview setelah acara cuti Edittext apakah mungkin di android saya mencoba dengan ini siapa pun dapat memberi tahu saya apa yang salah atau tidak mungkin di android?

saya mencoba setiap acara yang mungkin

objNextbet=getNextBets();
            Button btnbetNow =(Button)findViewById(R.id.btnBetNow);
            try
            {
            SimpleExpandableListAdapter expListAdapter =
                new SimpleExpandableListAdapter(
                    this,
                    createBetGroupList("next"), // groupData describes the first-level entries
                    R.layout.group_row, // Layout for the first-level entries
                    new String[] { "BetGroup" },    // Key in the groupData maps to display
                    new int[] { R.id.childname },       // Data under "colorName" key goes into this TextView
                    createBetChildList("next") ,    // childData describes second-level entries
                    R.layout.child_row, // Layout for second-level entries
                    new String[] { "betText","betRate","betID" },   // Keys in childData maps to display
                    new int[] { R.id.txtBetText, R.id.txtdecRate,R.id.txtstrBetID}  // Data under the keys above go into these TextViews

                ) {
                @Override 
                public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent)
                {          
                     final View childview = super.getChildView(groupPosition, childPosition,isLastChild, convertView, parent); 


                     final TextView txtBetText = (TextView)childview.findViewById(R.id.txtBetText);
                     final TextView txtstrBetID = (TextView)childview.findViewById(R.id.txtstrBetID);
                     final TextView txtdecRate = (TextView)childview.findViewById(R.id.txtdecRate);                  


                     String strBetGroup="";
                     for(int n = 0 ; n < objNextbet.size() ; n++ ) 
                        {
                         if(objNextbet.get(n).getBetText().toString().equals(txtBetText.getText().toString()))
                          {
                             strBetGroup=objNextbet.get(n).getstrBetGroupName().toString();
                          }
                        }



                     Button btnBetNow = (Button)childview.findViewById(R.id.btnBetNow);
                     btnBetNow.setTag(txtBetText.getText() + "-" +
                             txtstrBetID.getText() +"-" +txtdecRate.getText()+"-"+strBetGroup);

                     btnBetNow.setOnClickListener(new OnClickListener() 
                     {    
                        @Override             
                        public void onClick(View view) 
                        {                 
                           try
                           {
                               String TagValue=(String) view.getTag();
                               final String bet[] = TagValue.split("-");

                               final Dialog dialogbetNow = new Dialog(myucontext);
                               /** Disabling The PopUp Title Bar */
                               dialogbetNow.requestWindowFeature(Window.FEATURE_NO_TITLE); 

                               /** Set The Content For The PopUp */
                               dialogbetNow.setContentView(R.layout.popupbet);

                                /** Set The PopUp Deposit Balance */ 
                                  TextView txtCashcredit =(TextView)dialogbetNow.findViewById(R.id.txtCashcredit); 
                                  txtCashcredit.setText(Double.toString(objCGUserProfile.getUsedCredit()).toString());

                                  final TextView txtbetBetText = (TextView)dialogbetNow.findViewById(R.id.txtbetBetText);
                                  txtbetBetText.setText(bet[0]);

                                  TextView txtbetRate = (TextView)dialogbetNow.findViewById(R.id.txtbetRate);
                                  txtbetRate.setText(bet[2]);

                                  Button btnpopupBetNow = (Button)dialogbetNow.findViewById(R.id.btnpopupBetNow);
                                  btnpopupBetNow.setOnClickListener(new OnClickListener()
                              {

                                @Override
                                public void onClick(View v)
                                {

                                    final EditText ETStake = (EditText)dialogbetNow.findViewById(R.id.ETStake);

                                    if(ETStake.getText().toString().equals(""))
                                    {
                                        TextView txtError =(TextView)dialogbetNow.findViewById(R.id.txtError);
                                        txtError.setTextColor(Color.RED);
                                        txtError.setText("Please Enter cash.");
                                    }
                                    else
                                    {
                                        final double cash = Double.valueOf((String)ETStake.getText().toString()).doubleValue();

                                        ETStake.setOnFocusChangeListener(new EditText.OnFocusChangeListener()
                                        {    
                                            @Override
                                            public void onFocusChange(View v,boolean hasFocus) 
                                            {
                                                if (!hasFocus)
                                                {
                                                    // TODO: the editText has just been left 
                                                    TextView txtRisk = (TextView)dialogbetNow.findViewById(R.id.txtRisk);
                                                    TextView txtReturn = (TextView)dialogbetNow.findViewById(R.id.txtReturn);
                                                    txtRisk.setText(Double.toString(cash).toString());
                                                    double stake = Double.parseDouble(ETStake.getText().toString());
                                                    double rate = Double.parseDouble(bet[2]);
                                                    double betReturn = stake * rate;
                                                    txtReturn.setText(Double.toString(betReturn));
                                                }

                                            }
                                        });

                                    }
                                }
                            });

                                  ImageView imgCancel = (ImageView)dialogbetNow.findViewById(R.id.imgCancel);
                                  imgCancel.setOnClickListener(new OnClickListener() {

                                    @Override
                                    public void onClick(View v) 
                                    {
                                         try 
                                         {
                                           dialogbetNow.cancel();   
                                         }
                                         catch (Exception e)
                                         {
                                         }  
                                    }
                                });

                              dialogbetNow.show();

                           }

                           catch(Exception ex)
                           {
                               ex.toString();
                           }
                        } 
                        });                  

                     return childview;     
                } 

6
2018-04-29 10:40


asal


Jawaban:


Anda dapat mendaftar OnFocusChangeListener pada Anda EditText di dalam aktivitas Anda onCreate metode:

final EditText et = (EditText)findViewById(R.id.my_edit_text);
et.setOnFocusChangeListener(new View.OnFocusChangeListener()
{
    @Override
    public void onFocusChange(View v, boolean hasFocus)
    {
        if (!hasFocus)
            // TODO: the editText has just been left
    }
});

Di sini v parameter dari onFocusChange itu kamu EditText kontrol.

Juga, jika Anda ingin memperbarui TextView pada setiap perubahan dalam EditTextKonten, Anda harus memasukkan kode pembaruan Anda di dalam public void afterTextChanged(Editable s) metode yang terdaftar TextWatcher.

// Pastikan, bahwa itu txtRisk TextView adalah bagian dari dialogbetNow melihat.


17
2018-04-29 10:48



disini textMessage adalah editext Anda

 textMessage.addTextChangedListener(new TextWatcher(){
            public void afterTextChanged(Editable s) {
                i++;
                tv.setText(textMessage.getText.toString());
            }
            public void beforeTextChanged(CharSequence s, int start, int count, int after){}
            public void onTextChanged(CharSequence s, int start, int before, int count){}
        }); 

2
2018-04-29 10:48



Menggunakan onFocusChangeListener. Setiap tampilan akan memberi tahu Anda tentang kehilangan fokus melalui antarmuka itu.


1
2018-04-29 10:46