How to check the checkbox after receiving the message in android - android

I am making an application for android mobiles in which i have to receive the message string and then split that string in parts(each parts containing 2 characters).I am able to do up-to this much.
And after this now i have to check the checkbox depending on the string.
For ex-if my String is a1a2a3
then i have splited into a1, a2 & a3.Now i have a screen of 5 vertical check boxes.where 1st box represent a1,2nd one a2 and so on the 5th one representing a5.
Now after receieving the message(a1a2a3) i want that when i open the checkbox page then i should get the first three checkboxes to be checked.
On testing with debugger attached i found that i am able to receive the message and also i am able to split the message string but i am not able to apply check on the checkboxes.
Plz help me out.its very urgent.
Thanks in advance:)

Do this:
CheckBox checkBox;
if(A.a1==1){
checkBox = findViewById(R.id.Checkbox_a1);
checkBox.setChecked(true);
}
Whats the rocket science in this? Have u added the tag:
setContentView(R.layout.main);

Related

Programming in Android Studio to able the user to give three numbers and save them

in android stuido I would like to code an activity, where the user can input numbers. For, example he types the number to the textfield, click 'OK' button, then the textfield gets clear, he types the second number, than the third, and after they give the third number the program goes to another activity and sayst thanks for the free number. I would like to save the three numbers for further use and have them in an ascending order. How should I do it?
I agree with Andrii, this is a very vague and general question. To get you pointed in the right direction though, you would want a layout with an number based-editText widget (for the user input). I would then add the button, and then implement OnClickListener for the button so that everytime the button is pressed, it calls a method you will define that will store the value in an array or list (which can be sorted), along with some kind of tracker to keep track of how many numbers have been entered - then clearing the editText field so that another number can be input; on the third number, the method calls the activity via intent or some other way saying "thanks for the free number".
This is all general and it is going to take quite a bit of work and API Guide/DeveloperDocs searching on the Android web site.

How to display database contents in a new activity at onclick of a button?

thing is, if i click a button GETDATA - then a new activity starts new.java and i want it to display the contents of my database.
in this new.java i have strings name and id. and i have lined database and this class, such that name and id have the corresponding details that i want to display.
now the ques is, how to display them ?
if i have a
EditText ta;
ta=findViewBy(R.id.edittext1);
ta.setText(name);
should this work ?
it isnt working. also, i dont want user to change the contents and want to make this filed un-editable.
should i use
TextView tf;
ta=findViewBy(R.id.textview1);
tf.setText(name);
?
even this isnt happening.
what is the procedure for this ?
it is done by using append.
TextView ta;
ta=(TextEdit)findViewById(Ri.id.textView1);
String a=getData(1); // goto database, id is 1
ta.append(a);

Android switch text button?

I am developping an app that has some quotes but I am unable to have next/previous buttons to navigate between the quotes like in the attached image ??
can anybody help ?
http://img.technospot.net/Free-Android-app-Success-Quotes.jpg
If the only that that's changing is the quote, just have the next and previous buttons change the text on click to the next quote in the cycle.
I'm assuming you are genarating randoms numbers to show the quotes randomly. Just save the position of the quotes(are they stored in an array?) and save them in an Integers List every time the user clicks next.
List<Integer> intList = new ArrayList<Integer>();
So if the user wants to go back just get the previous number which was shown by accessing the list with :
intList.get(intList.size()-1);
You should provide more informations next time and be as precise as you can.

Can we added changing image/text on android app

Is there a way in android app that we can add some text or image and we can change that dynamically without adding new version. Like we have this text: Today's deal is: 1
then in a week if i want that text to show as: Today's deal is: 2.
Is there a way to do this, for an app which does not have a server and is stand alone app.
A text or image can be altered during run time; so how you choose to change that is up to you. You would have a simply switch statement depending on the day of the week for your specific example.
TextView tv = (TextView) findViewById(R.yourxml.name);
tv.setText("Monday!");
...
One way I can think of to achieve this is by writing a long value in the shared preferences for a Date object. Each time you start the application we will check if it's been 1 day since the value was saved. Also maintain the different string you want to display as string array in the resources.
I hope it helps...

How to uncheck the CheckBox, when limit exceeds in android?

Hello I am New to Android, My requirement is allow the user to check maximum 3 number of checkboxes. when user is trying to check fourth one should populate dailogue.
Iam trying but the problem is fourth one is not unchecking...
can any one help me...
Regards
Shiva.M
Just uncheck the checkbox using the following code block:
final CheckBox checkBox = (CheckBox) findViewById(R.id.checkbox_id);
if (checkBox.isChecked()) {
checkBox.setChecked(false);
}

Categories

Resources