Checkbox label should not be clickable - android

I am using checkbox in android and the state of checkbox is changing once i click on the text of the checkbox. "[CB] Text ". Is there any way to change this behaviour so that the state of checkbox will be changed once i click on the box and not the text.
Sorry this question would have already asked in the forum. But i was not able to find any queries related to this. Any suggestions would be really helpful for me.
-Thanks,
Ron...

The answer by jkhouw1 is the only way I can think of as well.
But please take a moment to make sure you really want this functionality. Every time you change the basic behavior of a, to the user, well know element you confuse more than you help. There are cases where you need such a change, but take a minute to make sure this is so!

Other than creating your own control, the easiest way would probably be to not display any text with the checkbox and in your layout use a textview for the text instead so you would have
[CB][TextView]

I think you are using [checkbox] [textview] in one layout tht is linear or relative,if i am right then set android:focusable = "false" android:clickable= "true" to checkbox.
i hope it will help you.

Related

Text editor options with Kotlin

I was wondering how to make a text editor toolbar for an android app using Kotlin.
I've already implemented the view as you can see here. But I can't find a way to make it work propperly. I've tried to use Spannable String and Typeface but I think that they are not what I am looking for.
When using spannable, I need to put some string. But I can't put a string because there may be no text yet.
Maybe using the textchange listener of the EditText would work? I've tried it too but it doesn't seem to fit into my logic.
This is what I was thinking about: A listener for every button. Whenever a button is pressed, add that style to the future text that will come. To specify the start and the end of the text, maybe I could take the current position of the cursor to specify the start and the position of the cursor whenever the button is "unpressed" to specify the end. But I can't find something that fits my logic.
Maybe you could give me some ideas, another logic...Which is the proper way to do it?
Thank you very much :)

Auto scroll down EditText

I have an Activity that consist in 3 buttons and a EditText, where I add (with EditText.append(String)) some text when the buttons are pressed... The problem is that i couldn't find the way to show the last text lines when they reach the lower limit of the EditText..
Sometimes it works, and the text go up as i add more text lines, but for example, when i touch the screen and move the EditText, it stays there..
The only "solution" that i found was the "scroller", but i don't understand how it works. Can anyone help me with this?
Thanks in advance.
It is not really the answer to the question, but for the ones that maybe have the same question as me:
I finally put a TextView in a ScrollView, and used the fullScroll(View.FOCUS_DOWN) functionality of the ScrollView.. This way i could see the end of the TextView.
I could do this because i didn't need to edit the text added.
Hope it helps.

How to grey out Views. Specifically an EditText?

Hey guy's
First of all thanks for reading this.
I'm having trouble to find a way to change my EditText when I loose focus to it.
I would like it to be greyed out when this happens, but I don't want it to be disabled because the user can touch it and edit the text later.
Anyone?
Greetings!
You can set different colors to the text based on an OnFocusChangeListener
Another option is to set a style in xml. See this question for details: Android: change style when focused
To change the opacity, use setAlpha. In this answer I show it how to do it in an animation: Two questions about custom app ui's and AlphaAnimation

Relative Layout Android

I have a layout of a user entry form.when i enter username and password and hit the submit button.the content should be saved and another div with three textboxes and editboxes should appear in the same page.
Replacing the content might not be the best solution.
Anyway, you can create all these elements together in the same layout and set the "div with three textboxes and editboxes" initially to "hidden".
After you have clicked the button and triggered the desired event, you grab the desired elements and make them visible while setting the unwanted elements to hidden again.
Charles Merriams answer would be the more elegant and cleaner way, this only answers the "base" question.
The magic word you need to look at is "Intent". You call your own application in order to switch layouts after the submit button.
You may find the Notepad tutorial useful.
You can try what DrColossos said or you can try by just setting a different contentview on button click.

Android ListView item highlight programmatically

I know it's been asked around but I haven't found quite the answer yet (new to Android so sorry about the ignorance)
my app's launch Activity has an EditText (called searchbox) , a ListView (designations) and a Spinner (types)
I use the EditText as a searchbox, I have to pass the string through a custom editing to make searching more flexible. After that I match that against the closest approximation I find in 'designations' and do
designations.setSelection(j);
As expected, this sets the desired item to the top of designations. But I can't find a way to highlight it via code.
NOW, i do know that if the device is in touch mode the highlighting of a selected item won't occur. So the last 4 lines of my searchbox's onTextChanged event are:
designations.setFocusable(true);
designations.setFocusableInTouchMode(true);
if (match==true) designations.setSelection(j);
if (st.length()==0) designations.setSelection(0);
to no avail.
now, i don't have any code on searchbox's afterTextChanged(Editable s);
so could anyone give me a clue on this?
regards
~dh
check out requestFocus() and maybe requestChildFocus()
Have you tried setting the actual View to be selected?
designations.setSelection(j);
designations.getSelectedView().setSelected(true);

Categories

Resources