I have a UI that has a handful of text entries that might be needed by the user. The users selects the type of entry from a spinner. when the selection is made I change the visibility of some edittext controls and change the label that goes with it.
The problem is the space where the edittext was is now blank and the screen layout looks screwy.
I put all of this in a table, hoping I could hide a row, but that didnt help either.
Any ideas short of make a new class for each one?
Instead of setting the visibility to View.HIDDEN, set it to View.GONE. From the description for View.GONE:
This view is invisible, and it doesn't
take any space for layout purposes.
Use with setVisibility(int).
just make sure u use SetVisibility(View.GONE)
Related
I have two TextView in my android code, one over other. The lower text view do not have onCLickListener set but the other TextView has, and also lower TextView is set invisible. The problem is that the upper text view do not respond on click as long as it is placed over the other text view. Please tell how can I solve this issue? I can not change components' positioning because of some reasons.
Seems like a z-index problem to me: your invisible view is placed on top of the visible one, which does not receive the click.
The click is received by the invisible one, that does nothing.
I've never experienced that, but you could try to define the visible view after the invisible in your xml file.
If it does not work, I believe that here can be something that could help you.
Make sure that the textview is gone not just invisible:
Eg.
textview.setVisibility(View.GONE).
This will make the textview leave instead of just making it invisible.
Apply following line on desired TextView and then check onClick event.
yourTextView.bringToFront();
I have an EditText in my layout which is used to get the search query from the user. I want to show a LinearLayout bellow it when user enters some characters and fill it with the results (This layout should appear after entering at least N characters). But I don't know how to show this layout?
I thought of putting the whole layout shown in the activity inside a FrameLayout and add the view when required, but there will be two problems:
The view will be added on the top left of the screen.
If I want to move it with adding some padding to it, all the area will correspond to the click event.
To explain what I want more, please take a look at this:
I hope this link will help you, you need to use AutoCompleteTextVIew
http://www.javatpoint.com/android-autocompletetextview-example
https://www.codeofaninja.com/2013/12/android-autocompletetextview-custom-arrayadapter-sqlite.html
These is two approaches for your case.
Use AutoCompleteTextView
Use android-popupwindow.
The former is easier and more acceptable, however if your want to customize the layout of the resulting search, for example arranging them in a gird view, you may what to use the latter option.
Although, AutoCompleteTextView internally uses the latter option.
I have an EditText with input_type "number".
It lives inside a layout which is an item inside a ListView.
The problem is the following:
when I touch the EditText, I quickly get the soft numerical keyboard, but in less than a second it automatically changes to regular soft keyboard showing all letters. Obviously, I want the numerical keyboard.
To add more weirdness to the problem, if I change the layout_height of the ListView from match_parent to wrap_content, the problem doesn't occur. But unfortunately I need to keep the ListView with height match_parent.
Anyone has any ideas?
Thanks!
I could be wrong but you may want to consider changing your design by placing any edit text fields within a scrollview. The getView method of your list adapter gets called multiple times at unpredictable intervals that you will not be able to control. This will cause any init code you have in xml or code to be re initialized over and over again with some interesting results. If you have multiple elements in your list items that may be what is cause the keyboard to "work" when you adjust the height.
How can I have more than one button, or a button and a text view in the same location in one layout but one on top of the other?
I want to have a button that is hidden most of the time, but occasionally will have a non intrusive popup that will prompt something. The rest of the time there will be a text view there that is a different size.
Please take a look at RelativeLayouts.
They use android:layout_below and android:layout_above to position elements below/above other elements.
Use TextView.setVisibility(View.VISIBLE) or TextView.setVisibility(View.GONE) depending on your condition and you may not need to put elements on top of each other in the layout.
I would like to change the layout when an EditText is clicked and the softkeyboard is shown, so all EditText views are still visible.
I know that you can use the following two, but this is not what i'm looking for.
android:windowSoftInputMode="stateUnchanged|adjustPan">
android:windowSoftInputMode="stateUnchanged|adjustResize">
I've got 8 EditText views spread over the whole screen. When one is clicked to change a value I would like to still see all the ET views but nicely arrange and not pushed in a weird view.
Is there an easy way to do this?
I think you are going to have to do this yourself, but one technique might be ...
Create a layout with the views arranged for the keyboard shown (for instance a new RelativeLayout) that overlays your standard layout. Set it's visibility to GONE. Then when you detect the event that shows the keyboard hide the current view and show the alternate one
I suppose you could also use a ViewSwitcher
If you are using both at the same time then it doesnt work.Set the attribute android:windowSoftInputMode="adjustPan" only.That should work.