autocompletetextview not working inside popup window

后端 未结 2 1754
隐瞒了意图╮
隐瞒了意图╮ 2021-01-27 13:38

I am new to android and i am trying to integrate auto complete text view inside popup window. But the auto complete action not working inside the popup window. If i

2条回答
  •  清歌不尽
    2021-01-27 14:12

    @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_my);

        final Button btnOpenPopup = (Button)findViewById(R.id.openpopup);
        btnOpenPopup.setOnClickListener(new Button.OnClickListener(){
    
            @Override
            public void onClick(View arg0) {
                LayoutInflater layoutInflater = (LayoutInflater)getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);
                View popupView = layoutInflater.inflate(R.layout.activity_popup, null);
    
                final PopupWindow popupWindow = new PopupWindow(
                        popupView, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT, true);
    
    
                popupView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
    
                final EditText text = (EditText)popupView.findViewById(R.id.editText); // to write Review notes
    
                final TextView txtRatingValue = (TextView)popupView.findViewById(R.id.txtRatingValue); // Rating Value
    
                final RatingBar   ratingBar = (RatingBar)popupView.findViewById(R.id.ratingBar);
                ratingBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
                    public void onRatingChanged(RatingBar ratingBar, float rating,
                                                boolean fromUser) {
    
                        txtRatingValue.setText(String.valueOf(rating));
    
                    }
                });
    
                // popupView.addListenerOnRatingBar();
    
    
                Button  ok = (Button )popupView.findViewById(R.id.ok); // Database Codes to store the apps rating and review Data
                ok.setOnClickListener(new Button.OnClickListener() {
    
                    @Override
                    public void onClick(View v) {
    
                        Toast.makeText(MyActivity.this, "Reminder Nikhil Keshri's Database code to Be added here....", Toast.LENGTH_LONG).show();
    
                    }
                });
    
                Button clear = (Button)popupView.findViewById(R.id.clear); // clearing button
                clear.setOnClickListener(new Button.OnClickListener() {
    
                    @Override
                    public void onClick(View v) {
                        text.setText("");
                        //  txtRatingValue.setText("0.0");
    
                    }
                });
    
    
                // text.setBackgroundColor();
                Button close = (Button)popupView.findViewById(R.id.close); // closing the popup window
                close.setOnClickListener(new Button.OnClickListener() {
    
                    @Override
                    public void onClick(View v) {
    
                        popupWindow.dismiss();
                    }
                });
    
                popupWindow.showAsDropDown(btnOpenPopup, -50, -70);
    
            }});
    }
    

提交回复
热议问题