logo
down
shadow

Get input text with customview without edittext android


Get input text with customview without edittext android

By : user2956490
Date : November 22 2020, 10:56 AM
will be helpful for those in need Try to create edittext dynamically and send the value to view.Here is my code.its best alternative ..
code :
public class CustomEditText extends EditText {

private KeyImeChange keyImeChangeListener;

public CustomEditText(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
}

public CustomEditText(Context context) {
    super(context);
}

public CustomEditText(Context context, AttributeSet attrs) {
    super(context, attrs);
}


public void setKeyImeChangeListener(KeyImeChange listener){
    keyImeChangeListener = listener;
}

public interface KeyImeChange {
    public void onKeyIme(int keyCode, KeyEvent event);
}

@Override
public boolean onKeyPreIme (int keyCode, KeyEvent event){
    if(keyImeChangeListener != null){
        keyImeChangeListener.onKeyIme(keyCode, event);
    }
    return false;
}
           MainActivity.editText2.setKeyImeChangeListener(new CustomEditText.KeyImeChange() {

                @Override
                public void onKeyIme(int keyCode, KeyEvent event) {
                //Update view on keyboard close
                      invalidate();


                }
            });


Share : facebook icon twitter icon
Android: Use edittext input to set text of a button?

Android: Use edittext input to set text of a button?


By : ramaro
Date : March 29 2020, 07:55 AM
it fixes the issue I save my edditext text: , First you would find the Button in question
code :
Button button1 = (Button)findViewById(R.id.button1);
SharedPreferences settings = getSharedPreferences("cars4sale",0);
String zipStr = settings.getString("zip", "");    
button1.setText(zipStr);
Java Android - Can't use OnClick functions outside of CustomView inside CustomView

Java Android - Can't use OnClick functions outside of CustomView inside CustomView


By : user7052842
Date : March 29 2020, 07:55 AM
To fix this issue (the code is dump from this question Android Shared Preferences)
create a class AppPreferences
code :
public class AppPreferences {
     public static final String KEY_DIFFICULTY = "difficulty";
     private static final String APP_SHARED_PREFS = AppPreferences.class.getSimpleName(); //  Name of the file -.xml
     private SharedPreferences _sharedPrefs;
     private Editor _prefsEditor;

     public AppPreferences(Context context) {
         this._sharedPrefs = context.getSharedPreferences(APP_SHARED_PREFS, Activity.MODE_PRIVATE);
         this._prefsEditor = _sharedPrefs.edit();
     }

     public String getDifficulty() {
         return _sharedPrefs.getString(KEY_DIFFICULTY, "");
     }

     public void saveDifficulty(String text) {
         _prefsEditor.putString(KEY_DIFFICULTY, text);
         _prefsEditor.commit();
     }
}
private AppPreferences _appPrefs;
public GameView(Context context, AttributeSet attributeSet) {
    super(context);
    _appPrefs = new AppPreferences(getApplicationContext());
    String difficulty = _appPrefs.getDifficulty();
_appPrefs.saveDifficulty("1"); //or "2" or "3"
Android EditText setText and input text in last?

Android EditText setText and input text in last?


By : a27mri
Date : March 29 2020, 07:55 AM
help you fix your problem I use EditText to input some information, and I setText in EditText. , I think you need setSelection to move to end of your text
code :
EditText et = (EditText)findViewById(R.id.edittext1);
et.setSelection(et.getText().length());
Android: EditText in CustomView not behaving as expected when touched

Android: EditText in CustomView not behaving as expected when touched


By : cantide5ga
Date : March 29 2020, 07:55 AM
Any of those help It looks like you are extending LinearLayout but never using it in your layout. From what you've posted, you aren't using the FormField at all and the only custom View I see is the ValidationIcon view. So hooking the touch events into EditText and ValidationIcon aren't occurring because you aren't using FormField in your layout.xml.
Rather than extending LinearLayout, why not just use the predefined methods and attributes to handle the behaviour you are trying to achieve. For example, displaying keyboard, requesting focus, and displaying hint:
code :
<EditText
    android:id="@+id/edit_text"
    android:layout_weight="1"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"
    **android:inputType="text"**
    **android:hint="@styleable/FormField_fieldInputHint"**
    android:padding="10dp"
    android:textColor="#2d6169"
    android:textSize="18sp"
    android:background="@color/transparent" />
//call this from onViewCreated to grab focus and begin the flow
editText.requestFocus();
//set focus listener to handle keyboard display
editText.setOnFocusChangeListener(new OnFocusChangeListener() {
     @Override
     public void onFocusChange(View v, boolean hasFocus) {
          if (!hasFocus) {
              InputMethodManager imm = (InputMethodManager)getSystemService(
  Context.INPUT_METHOD_SERVICE);
              imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);
     } else {
              InputMethodManager imm = (InputMethodManager)getSystemService(
  Context.INPUT_METHOD_SERVICE);
              imm.showSoftInputFromWindow(myEditText.getWindowToken(), 0);
     }
});
Unable to retrieve input text from EditText in Android

Unable to retrieve input text from EditText in Android


By : Anshu Kumar
Date : March 29 2020, 07:55 AM
I wish this helpful for you I think that click callback ins´t take the correct instance of yours TextViews. Try get these values inside click button:
code :
class LoginPage : Fragment()
{

    lateinit var loginId:EditText
    lateinit var password:EditText
    lateinit var loginButton:Button

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View?

        {
            var binding:FragmentLoginPageBinding = DataBindingUtil.inflate(inflater,R.layout.fragment_login_page,container,false)
            var view  = binding.root
            loginId = view.findViewById(R.id.edittext_userid)
            password = view.findViewById(R.id.edittext_password)
            loginButton = view.findViewById(R.id.button_login)

            loginButton.setOnClickListener {
                val text1: String = loginId.text.toString()
                val text2: String = password.text.toString()
                Navigation.findNavController(it).navigate(LoginPageDirections.actionLoginPageToMainPage(text1,text2))
                Toast.makeText(context,text1,Toast.LENGTH_SHORT).show() //<-- shows empty string
           }

           return view
        }
}
this.runOnUiThread {
     Toast.makeText(context,text1,Toast.LENGTH_SHORT).show() //<-- shows empty string
}
Related Posts Related Posts :
  • Android Studio gradle build failed for hello world app
  • Slide a layout up from bottom of screen
  • Play HTML5 video in iOS/Android native media player
  • How to rescale a bitmap file in android?
  • No view found for id 0x for fragment after rotation?
  • Define different themable styles to the same widget types
  • ProGuard not working in my app
  • FragmentTransaction from BaseAdapter
  • Connecting multiple devices in a Wifi Direct group
  • Why TabActivity is deprecated in android
  • How to capture low resolution picture using android camera
  • android preferenceactivity padding in landscape orientation
  • How can I store cookie in webview?
  • Passing variables from one activity to another
  • Create Multicolored Pie Chart in Android Studio
  • how to kill progress dialog in android
  • Show Error on the tip of the Edit Text Android
  • How do I use getWindowManager() by another java file
  • fetching images from gallery on android phones with internal storage
  • How to discover devices like Google TV and Nexus-Q using MediaRoute API on Android?
  • "Unfortunately your app stopped working"- Facebook Integration for Android
  • How to animate button in android?
  • Resource Not Found Exception in class without context or activity
  • Launching Android Netflix App And Passing Video Id
  • Making a Phone Call with a Number Extension
  • NullPointerException at BoringLayout.isBoring is anything but boring
  • java.lang.RuntimeException: Unable to get provider
  • Testing custom Views with Robolectric
  • tools:listheader doesn't work although tools:listitem does
  • oppo, vivo app kill notification not coming in android fcm
  • OnClick Method could not function correctly with if else statement
  • Best method to download image from url in Android
  • How can I open Drawer Layout moving all the view and not just slide over?
  • how to show profile pictures of friends in a list view?
  • Creating TimePickerDialog with custom style in Android
  • Android 2.3.6 support library v7 option menu is missing
  • need of vblank in Display subssytem
  • Android MP4 stream - Video cannot be played
  • FastAdapter: Undo button does not show up after swipe
  • What are reasons to pass getActivity as the LifecycleOwner to the LiveData's observe method in a fragment?
  • Implement Face Recognition in Android
  • Titanium studio cannot run "titanium" command in terminal
  • How to execute command line ffmpeg commands programatically in android?
  • Make Android List Items clickable with each item pointing to a different link
  • listview runs successfully, but nothing is display in emulator
  • How to zoom in a bitmap with high resolution?
  • Passing listView data through intent
  • Google map route direction show by arrows in android v2
  • how to start "uiautomator test run" from android code?
  • Proguard in Android Library
  • Alarm Clock from GIT - Gives error - Android
  • Mock injection using Mockito - Android
  • Get Bitmap from universal image loader
  • Unable to include custom font in android
  • Basics on using logcat in Android development
  • Android: Clear cache programmatically
  • Android: pass object without serialization
  • Can not scroll and click item on gridview inside scrollview
  • Android device keeps disconnecting from adb / eclipse
  • Volley cannot create cache directory. Could not clean up file
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org