I am beginner in Android. I created a circular seekarc with temperature showing text and I added in middle of seekarc. The text value is starting with 10 and ending with value is 20.
I want to read each text value position for seekarc. If the text value position is false, then seekarc value position is also false.
How can I achieve this? Can any one help me?
Below is my code:
seekarc = (SeekArc) v.findViewById(R.id.seekAr);
seekArcprogres = (TextView) v.findViewById(R.id.seekArcProgres);
seekarc.setOnSeekArcChangeListener(new SeekArc.OnSeekArcChangeListener() {
#Override
public void onProgressChanged(
SeekArc seekArc, final int progress,
boolean fromUser) {
seekArcprogres.setText(String.valueOf(progress + 10));
switch (progress) {
case 0:
Op.processInputCmd(getArguments().getString(""), Manager.Command.EMP_16, false);
break;
case 1:
Op.processACButtonInputCmd(getArguments().getString(""), Manager.Command.EMP_10, false);
break;
case 2:
;
Op.processInputCmd(getArguments().getString(""), Manager.Command.EMP_11, false);
break;
case 3:
Op.processInputCmd(getArguments().getString(""), Manager.Command.EMP_12, false);
break;
}
seekArcprogres.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Op.processInputCmd(getArguments().getString(""), Manager.Command.EMP_10_LR, false);
}
});
seekArcprogres.setOnLongClickListener(new View.OnLongClickListener() {
#Override
public boolean onLongClick(View v) {
Op.processInputCmd(getArguments().getString(""), Manager.Command.EMP_10_LR, true);
return true;
}
});
seekArcprogres.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Op.processInputCmd(getArguments().getString(""), Manager.Command.EMP_11_LR, false);
}
});
seekArcprogres.setOnLongClickListener(new View.OnLongClickListener() {
#Override
public boolean onLongClick(View v) {
Op.processInputCmd(getArguments().getString(""), Manager.Command.EMP_17_LR, true);
return true;
}
#Override
public void onStartTrackingTouch(
SeekArc seekArc) {
}
#Override
public void onStopTrackingTouch(
SeekArc seekArc) {
}
});
Related
I'm creating converter (distance) 4 Android. My idea was do it like:
EditText - user put value f.e. 40
two Spinners - first to set started unit and second to set destination unit f.e. first [cm] second [meters]
TextView with result
Button to calculating
I did functions with calculating values, the problem is how to choose units
this is my code which didn't work
spinnerP = (Spinner) findViewById(R.id.spinnerPocz);
ArrayAdapter<CharSequence> adapterP = ArrayAdapter.createFromResource(this, R.array.odlegloscArray, R.layout.support_simple_spinner_dropdown_item);
adapterP.setDropDownViewResource(R.layout.support_simple_spinner_dropdown_item);
spinnerP.setAdapter(adapterP);
spinnerP.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
#Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
//Toast.makeText(getBaseContext(), parent.getItemIdAtPosition(position) + " selected", Toast.LENGTH_LONG).show();
}
#Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
spinnerD = (Spinner) findViewById(R.id.spinnerDoc);
ArrayAdapter<CharSequence> adapterD = ArrayAdapter.createFromResource(this, R.array.odlegloscArray, R.layout.support_simple_spinner_dropdown_item);
adapterD.setDropDownViewResource(R.layout.support_simple_spinner_dropdown_item);
spinnerD.setAdapter(adapterD);
spinnerD.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
#Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if (spinnerP.getItemAtPosition(position) == 0) {
switch (position) {
case 0:
Toast.makeText(getApplicationContext(), "zmień wartość docelową", Toast.LENGTH_SHORT).show(); //units the same
break;
case 1:
btnOblicz.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
metryNaKm(); //meters to km
}
});
break;
case 2:
btnOblicz.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
metryNaCm(); //meters to cm
}
});
break;
case 3:
btnOblicz.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
metryNaCale(); //meters to inch
}
});
break;
//etc.
//then there is
else if (spinnerP.getItemAtPosition(position) == 1) {
switch (position) {
case 0:
btnOblicz.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
kilometryNaM(); //km to meters
//etc
I guess that doing it like this is horrible, but I'mma not advanced, I am open to suggestions
What you should do is to remove all your OnItemselectedListeners, and use only one OnClickListener for your button. Then use getSelectedItemPosition.
btnOblicz.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
int selectedP = spinnerP.getSelectedItemPosition();
int selectedD = spinnerD.getSelectedItemPosition();
switch(selectedP){
case 0:
switch(selectedD){
case 1:
convertFrom0to1();
break;
case 2:
convertFrom0to2();
....
}
break;
....
}
}
});
I am trying to make a simple drawing application, but am running into problems switching the paint color.Here is the tutorial I used to get to the point I am at. Here is my code:
Drawing_View.java
public class Drawing_View extends View {
private Path path = new Path();
private Paint paint = new Paint();
public String paint_color = "#FFBB00";
public Drawing_View(Context context, AttributeSet attrs) {
super(context, attrs);
paint.setAntiAlias(true);
paint.setStrokeWidth(5f);
paint.setColor(Color.parseColor(paint_color));
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeJoin(Paint.Join.ROUND);
}
#Override
protected void onDraw(Canvas canvas) {
canvas.drawPath(path, paint);
}
#Override
public boolean onTouchEvent(MotionEvent event) {
float eventY = event.getY();
float eventX = event.getX();
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
// Set a new starting point
path.moveTo(eventX, eventY);
return true;
case MotionEvent.ACTION_MOVE:
// Connect the points
path.lineTo(eventX, eventY);
break;
default:
return false;
}
invalidate();
return true;
}
}
Here is the code for the activity the custom view sits inside.
Drawing_Main.java
public class Drawing_Main extends ActionBarActivity {
Button green_light,green_dark,blue_light,blue_dark,blue_verydark,purple,magenta,red,orange_dark,orange_light,orange_lightest,yellow,black;
String btn_color_hex;
SharedPreferences.Editor editor = getSharedPreferences("paint_color", MODE_PRIVATE).edit();
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_emoji_creation);
green_light = (Button)findViewById(R.id.button1);
green_dark = (Button)findViewById(R.id.button2);
blue_light = (Button)findViewById(R.id.button3);
blue_dark = (Button)findViewById(R.id.button4);
blue_verydark = (Button)findViewById(R.id.button5);
purple = (Button)findViewById(R.id.button6);
magenta = (Button)findViewById(R.id.button7);
red = (Button)findViewById(R.id.button8);
orange_dark = (Button)findViewById(R.id.button9);
orange_light = (Button)findViewById(R.id.button10);
orange_lightest = (Button)findViewById(R.id.button11);
yellow = (Button)findViewById(R.id.button12);
black = (Button)findViewById(R.id.button13);
green_light.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
btn_color_hex="#0fad00";
editor.putString("paint_color_hex", btn_color_hex);
editor.commit();
}
});
green_dark.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
}
});
blue_light.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
}
});
blue_dark.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
}
});
blue_verydark.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
}
});
purple.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
}
});
magenta.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
}
});
red.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
}
});
orange_light.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
}
});
orange_lightest.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
}
});
orange_dark.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
}
});
yellow.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
}
});
black.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
}
});
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_emojicreation, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
As you can see I started exploring the sharedPreferences option, after my attempt to create a service failed. If a Service is the best option, how can I make Drawing_View.java constantly listen for color changes? Thanks everyone!
You could add a setPaintColor method to your Drawing_View class. That way, you would not need to use SharedPreferences
and you could just change the paint color in your onClickListeners.
Something like this should work:
In your Drawing_View class, add:
public void setPaintColor (String color) {
paint.setColor(Color.parseColor(color));
}
In your onClickListener, call the setPaintColor method:
drawingView.setPaintColor(color);
I assume that your Drawing_View is already instantiated.
Update
You need to instantiate your Drawing_View the same way you instantiated the Buttons in your activity's onCreate method.
public class Drawing_Main extends ActionBarActivity {
...
Drawing_View drawingView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_emoji_creation);
drawingView = (Drawing_View)findViewById(R.id.drawing_view);
green_light = (Button)findViewById(R.id.button1);
...
I hope this helps.
I want to disable my Seekbar and buttons with a switch which is Powerswitch
Here is a code snippet:
seekBar1.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
#Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
String sval = String.valueOf(i);
speakerVal.setText(sval);
}
#Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
#Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
// button - Favorite Channel ABC
cabc = (Button) findViewById(R.id.buttonABC);
cabc.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// Set Favorite
curChannel.setText("007");
}
});
and here is my switch code:
final Switch switch1 = (Switch) findViewById(R.id.switch1);
switch1.setOnCheckedChangeListener(this);
more switch code:
public void onSwitchClicked(View view) {
final TextView PowerSwitch = (TextView) findViewById(R.id.PwrSwitchVal);
Switch sw = (Switch) view;
if (sw.isChecked()) {
PowerSwitch.setText("ON");
pwr = true;
} else {
PowerSwitch.setText("OFF");
pwr = false;
}
}
I know I can use the switch.isChecked(), but when I change the seekba1.setEnabled(false), I can't seem to get it to turn back on.
I haven't even tried to disable the buttons yet.
any help would be appreciated.
In your onSwitchClicked method, you should be calling seekbar.setEnabled in the if checked if-else statement. If checked seekbar.setEnabled(true) else seekbar.setEnabled(false)
try this.
switch1.setOnCheckedChangeListener(new OnCheckedChangeListener() {
#Override
public void onCheckedChanged(CompoundButton arg0,
boolean arg1) {
if (arg1) {
seekbar1.setEnabled(true);
}
else{
seekbar1.setEnabled(false);
}
}
});
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
hi i am making a dictionary app and i want that when i open a word from a listview , then in the word page (word.class) (where the word meaning is explained), i want to add that word into a favorite.class activity in a listview shape and later on i can retrive that word from the listview.
i want to hit the favorite button in one java class and to save that word(string which is class name for that word) in anathor activity of favorite.class. the favorite button is actually is the menu item visible on the action bar. please explain me all the code and the way how can i do this..please give some code so to acomplish it.
public class Atherosclerosis extends Activity {
// declare variables for the table of content and paragraph heading here//
ScrollView scrollView;
TextView sign_atherosclerosis;
TextView sign_id;
TextView def_id;
TextView def_atherosclerosis;
TextView riskfac_id;
TextView riskfac_atherosclerosis;
TextView pathophy_id;
TextView pathophy_atherosclerosis;
TextView Dx_id;
TextView Dx_atherosclerosis;
TextView Rx_id;
TextView Rx_atherosclerosis;
TextView prevent_id;
TextView prevent_atherosclerosis;
TextView compl_id;
TextView compl_atherosclerosis;
#SuppressLint("NewApi")
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.atherosclerosis);
//here relate the variable for clickonlistener activity and direct scrolldown activity //
final ScrollView scrollView=(ScrollView)findViewById(R.id.scrollatherosclerosis);
TextView sign_id=(TextView)findViewById(R.id.Signandsymptomps_id);
final TextView sign_atherosclerosis=(TextView)findViewById(R.id.Signandsymptoms_atherosclerosis);
TextView def_id=(TextView)findViewById(R.id.definition_id);
final TextView def_atherosclerosis=(TextView)findViewById(R.id.definition_atherosclerosis);
TextView riskfac_id=(TextView)findViewById(R.id.riskfactor_id);
final TextView riskfac_atherosclerosis=(TextView)findViewById(R.id.riskfactor_atherosclerosis);
TextView pathophy_id=(TextView)findViewById(R.id.pathophysiology_id);
final TextView pathophy_atherosclerosis=(TextView)findViewById(R.id.pathophysiology_atherosclerosis);
TextView Dx_id=(TextView)findViewById(R.id.Diagnosis_id);
final TextView Dx_atherosclerosis=(TextView)findViewById(R.id.diagnosis_atherosclerosis);
TextView Rx_id=(TextView)findViewById(R.id.treatment_id);
final TextView Rx_atherosclerosis=(TextView)findViewById(R.id.treatment_atherosclerosis);
TextView prevent_id=(TextView)findViewById(R.id.prevention_id);
final TextView prevent_atherosclerosis=(TextView)findViewById(R.id.prevention_atherosclerosis);
TextView compl_id=(TextView)findViewById(R.id.complication_id);
final TextView compl_atherosclerosis=(TextView)findViewById(R.id.complication_atherosclerosis);
// this code is used for the action bar color change//
ActionBar bar = getActionBar();
bar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#6B8E23")));
getActionBar().setDisplayHomeAsUpEnabled(true);
getActionBar().setHomeButtonEnabled(true);
// this is the code for jumping from the table of content to the paragraph//
sign_id.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
scrollView.post(
new Runnable() {
#Override
public void run() {
new CountDownTimer(300, 20) {
#Override
public void onTick(long millisUntilFinished) {
scrollView.scrollTo(0, (int) (sign_atherosclerosis.getBottom()-millisUntilFinished));
}
#Override
public void onFinish() {
}
}.start();
}
}
);
}
});
def_id.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
scrollView.post(
new Runnable() {
#Override
public void run() {
new CountDownTimer(300, 20) {
#Override
public void onTick(long millisUntilFinished) {
scrollView.scrollTo(0, (int) (def_atherosclerosis.getBottom()-millisUntilFinished));
}
#Override
public void onFinish() {
}
}.start();
}
}
);
}
});
riskfac_id.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
scrollView.post(
new Runnable() {
#Override
public void run() {
new CountDownTimer(300, 20) {
#Override
public void onTick(long millisUntilFinished) {
scrollView.scrollTo(0, (int) (riskfac_atherosclerosis.getBottom()-millisUntilFinished));
}
#Override
public void onFinish() {
}
}.start();
}
}
);
}
});
pathophy_id.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
scrollView.post(
new Runnable() {
#Override
public void run() {
new CountDownTimer(300, 20) {
#Override
public void onTick(long millisUntilFinished) {
scrollView.scrollTo(0, (int) (pathophy_atherosclerosis.getBottom()-millisUntilFinished));
}
#Override
public void onFinish() {
}
}.start();
}
}
);
}
});
Dx_id.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
scrollView.post(
new Runnable() {
#Override
public void run() {
new CountDownTimer(300, 20) {
#Override
public void onTick(long millisUntilFinished) {
scrollView.scrollTo(0, (int) (Dx_atherosclerosis.getBottom()-millisUntilFinished));
}
#Override
public void onFinish() {
}
}.start();
}
}
);
}
});
Rx_id.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
scrollView.post(
new Runnable() {
#Override
public void run() {
new CountDownTimer(300, 20) {
#Override
public void onTick(long millisUntilFinished) {
scrollView.scrollTo(0, (int) (Rx_atherosclerosis.getBottom()-millisUntilFinished));
}
#Override
public void onFinish() {
}
}.start();
}
}
);
}
});
prevent_id.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
scrollView.post(
new Runnable() {
#Override
public void run() {
new CountDownTimer(300, 20) {
#Override
public void onTick(long millisUntilFinished) {
scrollView.scrollTo(0, (int) (prevent_atherosclerosis.getBottom()-millisUntilFinished));
}
#Override
public void onFinish() {
}
}.start();
}
}
);
}
});
compl_id.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
scrollView.post(
new Runnable() {
#Override
public void run() {
new CountDownTimer(300, 20) {
#Override
public void onTick(long millisUntilFinished) {
scrollView.scrollTo(0, (int) (compl_atherosclerosis.getBottom()-millisUntilFinished));
}
#Override
public void onFinish() {
}
}.start();
}
}
);
}
});
}
// this is for the options selected from the menu button of mobile//
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.atherosclerosis, menu);
return true;
}
// for starting activity from the option or menu//
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Take appropriate action for each action item click
switch (item.getItemId()) {
case R.id.id_search:
Intent newActivity0 = new Intent(this,Search.class);
startActivity(newActivity0);
return true;
case R.id.id_favorit:
SharedPreferences sp = this.getSharedPreferences("bookmarks", MODE_PRIVATE);
Editor editor = sp.edit();
editor.putString("favorite", "com.kmcpesh.shortreviewofcardiology.Favorite");
editor.commit();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
this is my favorite.class activity
public class Favorite extends Activity {
private TextView mEmptyText;
private LinearLayout mBookmarkLayout;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.favorite);
mEmptyText = (TextView) findViewById(R.id.empty_textview);
mBookmarkLayout = (LinearLayout) findViewById(R.id.bookmark_insert_point);
getAllKeys();
}
private void getAllKeys()
{
SharedPreferences sp = this.getSharedPreferences("bookmarks", MODE_PRIVATE);
Map<String,?> keys = sp.getAll();
int count = 0;
for(Map.Entry<String,?> entry : keys.entrySet())
{
String value = entry.getValue().toString();
System.out.println("!!!!!!!!!!!!!!!!!value = "+value);
String delimiter = ",";
String[] values_array = value.split(delimiter);
addBookmark(values_array);
count++; //keep track of the number of bookmarks
}
//if there are no bookmarks, display a text view saying so. Otherwise, make the text view go away
if (count == 0)
{
mEmptyText.setVisibility(View.VISIBLE);
mEmptyText.setText(getString(R.string.no_bookmark));
}
else
mEmptyText.setVisibility(View.GONE);
}
#SuppressWarnings("deprecation")
private void addBookmark(String[] values_array)
{
LayoutInflater vi = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = vi.inflate(R.layout.favorite, null);
TextView text = (TextView) v.findViewById(R.id.bookmark_text);
text.setText(values_array[1]);
// insert into main view
mBookmarkLayout.addView(v, 0, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT));
System.out.println("!!!!!!!!!!!!!!!!!!!!Just added a view");
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.favorite, menu);
return true;
}
}
SharedPreferences in Android is generally used to store key=value pairs, not lists such as the one you describe. To store a value into SharedPreferences, you can do this:
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
Editor ed = sp.edit();
ed.putString("myKey", "myValue");
And then to retrieve a string key from SharedPreferences, you would do this:
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
String value = sp.getString("myKey", "");
You could have a comma-delimited list of favorite words stored in here, and just parse the list:
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
Editor ed = sp.edit();
ed.putString("favorites", "dog,cat,bird,fish");
And then to retrieve them:
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
String favorites = sp.getString("myKey", "");
String[] words = values.split(",");
System.out.println(Arrays.toString(words));
Then you have an array containing all of your favorite words.
[dog, cat, bird, fish]
I search on many websites and many tutorials how can I get the data from editText and radioGroup and spinner DIRECTLY When the user input the data
I tried with this:
MyEditText.setOnKeyListener(new OnKeyListener() {
public boolean onKey(View view, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_ENTER) {
{case1.setName(CaseName.getText().toString());
}
return true;
}
return false;
}
});
but it didn't take the data, I just use button to make that as shown below:
Test.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.cancel1:
try
{
// 1-Name
case1.setName(CaseName.getText().toString());
}catch(Exception e){
}
break;
}
}});
Can anyone explain what shall I use to save the data in Object(case1) directly when the user input it ?
editext.addTextChangedListener(new TextWatcher() {
#Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// s is your text .
}
#Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}
#Override
public void afterTextChanged(Editable s) {
}
})
for Radio button
checkbox.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// Perform action on clicks, depending on whether it's now checked
if (((CheckBox) v).isChecked()) {
Toast.makeText(HelloFormStuff.this, "Selected", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(HelloFormStuff.this, "Not selected", Toast.LENGTH_SHORT).show();
}
}
});