1) How we lock/unlock a EditText in android ?
or
How we prevent EditText to take input in android ?
Answer :- Here is the sample project to show how we can prevent "EditText" to take input in android.
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<EditText android:id="@+id/textbox" android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<Button android:id="@+id/btnLockUnlock" android:layout_width="wrap_content" android:layout_height="wrap_content"/>
</LinearLayout>
Main.java
package com.androd.satya;
import android.os.Bundle;
import android.text.InputFilter;
import android.text.Spanned;
import android.view.View;
import android.app.Activity;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class Main extends Activity{
private EditText editText;
private boolean value = false;
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
editText = (EditText) findViewById(R.id.textbox);
Button btnLockUnlock = (Button) findViewById(R.id.btnLockUnlock);
btnLockUnlock.setText("Lock/Unlock");
btnLockUnlock.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
if (value){
value = false;
} else{
value = true;
}
lockUnlock(value);
}
});
}
private void lockUnlock(boolean value){
if (value){
Toast.makeText(this, "Lock the EditText", Toast.LENGTH_LONG).show();
editText.setFilters(new InputFilter[]{
new InputFilter(){
@Override
public CharSequence filter(CharSequence source,int start,int end,Spanned dest,int dstart,int dend) {
return source.length() < 1 ? dest.subSequence(dstart,dend):"";
}
}
});
} else{
Toast.makeText(this, "UnLock the EditText", Toast.LENGTH_LONG).show();
editText.setFilters(new InputFilter[]{
new InputFilter(){
//@Override
public CharSequence filter(CharSequence source,int start,int end,Spanned dest,int dstart,int dend){
return null;
}
}
});
}
}
}
CAN YOU SEND ME SOME MORE TUTORIALS WITH OUTPUT!
ReplyDelete(TELEPHONY,WIFI,BLUETOOTH,LAYOUT)PLS
THANKS
Nice Blog ! Do you need instant help to fix your QuickBooks issues? If yes, we are here to help you. Dial our QuickBooks Toll Free Phone Number +1-800-986-4607 now.our team have are 24*7 availability & very Experienced.
ReplyDeleteView on Map: https://tinyurl.com/yyah7zez.
Whenever you face any technical glitches, you can call us at our QuickBooks Support Phone Number 1(800)986-4591 We will deliver you the finest solutions. Do not go here and there as we are here to assist you in every possible manner. Connect with us now!. For More Visit: http://www.santrasolutions.com/quickbooks-support-phone-number/
ReplyDeletehttps://tinyurl.com/y569xkcy
Nice Blog ! Let our support team solve your issues. No matter how complex the problem is, we are always here to support you. Right from the installation process to resolving any complex error. Dial our QuickBooks Customer Service Number 1-800-986-4607.
ReplyDeleteView on Map: https://tinyurl.com/vq37tnv
Excellent and very informative blog click here
ReplyDeleteQuickbooks Proadvisor Support Phone Number and for more detail dial on 844-908-0801
QuickBooks Desktop Payroll Support Phone Number
ReplyDeleteQuickBooks For Mac Support Phone Number
QuickBooks For Mac Support Phone Number
ReplyDeleteQuickBooks Support Phone Number Seattle
QuickBooks Support Phone Number California
quickBooks Support Phone Number Pennsylvania
QuickBooks Support Phone Number Texas
Nice Blog ! Do you Need instant help fixing problems with your QuickBooks? Now dial our QuickBooks Payroll Support Phone Number 855 -9O7-O4O6! We have technical experts who can instantly fix your problems.
ReplyDeleteIf you need help in solving issues you are facing in any of the above versions, you can connect with us at our QuickBooks Support Phone Number New York 855-907-0406.
ReplyDeleteView On Map: QuickBooks Support Phone Number.
Great content and very helpful!
ReplyDeleteworried about QuickBooks support and any kind of help not to worry more.just make call to our 24*7 Expert support to fix it instant.
Dial QuickBooks Helpline number +1-844-908-0801.