Android solution EditText put into the Popupwindow, the original copy, paste, select all, the failure of the selection function _android

Source: Internet
Author: User

1, the original is EditView put to the Popupwindow, found that EditView original copy, paste, select all, the selection function is invalid, so they replaced with dialogfragment Popupwindow

Directly on the code

①, first look at the layout file

<?xml version= "." Encoding= "utf-"?> <linearlayout xmlns:android= " Android "Android:layout_width=" Match_parent "android:layout_height=" match_parent "android:gravity=" Bottom "Android : orientation= "Vertical" > <linearlayout android:id= "@+id/ll_background_dialog" android:layout_width= "Match_" Parent "android:layout_height=" DP "android:layout_weight=" "android:background=" # "Android:alpha=". "Android:o rientation= "Horizontal" > </LinearLayout> <scrollview android:layout_width= "Match_parent" Android: layout_height= "Wrap_content" android:background= "@android: Color/white" > <linearlayout android:layout_width= "Match_parent" android:layout_height= "wrap_content" android:background= "#ffcdcdcd" android:orientation= "vertical"
> <relativelayout android:layout_width= "match_parent" android:layout_height= "wrap_content" > <ImageView Android:id= "@+id/iv_quxiao_popup" android:layout_width= "wrap_content" android:layout_height= "Wrap_conten"T "android:padding=" DP "android:src=" @drawable/popup_comment_no "/> <textview android:layout_width=" Wrap_ Content "android:layout_height=" wrap_content "android:layout_centerinparent= true" android:text= "Speak" Android: Textcolor= "#" android:textsize= "sp"/> <imageview android:id= "@+id/iv_write_popup" android:layout_width= "wrap" _content "android:layout_height=" Wrap_content "android:layout_alignparentend=" true "Android:layout_ Alignparentright= "true" android:padding= "DP" android:src= "@drawable/popup_commnet_ok"/> </relativelayout > <edittext android:id= "@+id/et_comment_popup" android:layout_width= "Match_parent"
Wrap_content "android:layout_margin=" DP "android:background=" #ffffff "android:gravity=" Top "android:hint=" message Here " Android:minlines= "" "/> <relativelayout android:layout_width=" match_parent "android:layout_height=" Wrap_ Content "Android:layout_marginbottom=" DP "android:layout_marginleft=" DP "android:layout_marginright=" DP "> < TextView
Android:layout_width= "Wrap_content" android:layout_height= "Wrap_content" android:layout_alignparentright= "true"
android:text= "Civilized Internet" android:textsize= "sp"/> </RelativeLayout> </LinearLayout> </ScrollView>  </LinearLayout>

②, look at the custom diaglogfragment code

Import Android.annotation.SuppressLint;
Import Android.content.Context;
Import Android.os.Bundle;
Import Android.view.LayoutInflater;
Import Android.view.View;
Import Android.view.ViewGroup;
Import Android.view.WindowManager;
Import Android.view.inputmethod.InputMethodManager;
Import Android.widget.EditText;
Import Android.widget.ImageView;
Import Android.widget.LinearLayout;
Import Android.widget.Toast;
Import org.json.JSONException;
Import Org.json.JSONObject;
Import Java.util.HashMap;
Import Java.util.Map;
Import; /** * A Simple {@link Fragment} subclass. */@SuppressLint ("Validfragment") public class Customdialogfragment extends Dialogfragment {private ImageView Iv_quxiao _popup;//Cancel button private ImageView iv_write_popup; Confirm Button Private EditText et_comment_popup;//comment content private LinearLayout ll_background_dialog;//container Private Boolean
Iscommenting = false;
Private String uid;
Private String ID;
Private String CID; 
Public customdialogfragment (string uid, string ID, String cid) {this.uid = UID; = id; this.cid = CID;} @Override public void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);// This code means to let dialogfragment pop up when stained full screen SetStyle (Dialogfragment.style_normal, Android.; @Override public view Oncreateview (Layoutinflater inflater, ViewGroup container, Bundle savedinstancestate) {View view
= Inflater.inflate (r.layout.popup_write_comment, NULL); Let the dialogfragment background be transparent Getdialog (). GetWindow (). setbackgrounddrawable (New colordrawable (CoLor.
Initview (view);
Initevent ();
return view; }//Initialize view private void Initview (view view) {Iv_quxiao_popup = (ImageView) View.findviewbyid (; iv_
Write_popup = (ImageView) View.findviewbyid (;
Et_comment_popup = (edittext) View.findviewbyid (;
Ll_background_dialog = (linearlayout) View.findviewbyid (; private void Initevent () {//Cancel Iv_quxiao_popup.setonclicklistener (new View.onclicklistener () {@Override public void on
Click (view view) {dismiss ();}}); Confirm Send Iv_write_popup.setonclicklistener (new View.onclicklistener () {@Override public void OnClick (view view) {if Et_c Omment_popup.gettext (). toString (). Length () >) {if (!iscommenting) {iscommenting = true;} else {Toast.maketext (geta
Ctivity (), "is commenting, do not repeat", Toast.length_long). Show ();
} else {Toast.maketext (getactivity (), "Content cannot be empty", Toast.length_short). Show ();}
}); Ll_background_dialog.setonclicklistener (New View.onclickListener () {@Override public void OnClick (view view) {dismiss ();}}); }

3. How to use

Fragmentmanager manager = Getsupportfragmentmanager ()//The fragment of V or the customdialogfragment in the app bag
Dialogfragment = new Customdialogfragment (UID, ID, CID);

Effect chart

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.