Remove Unwanted Space - android

I am trying to hide unwanted TextView and EditText fields dynamically using my program. The code is working, but the hidden fields is being replaced with blank space. I wish the other contents below the hidden fields must be automatically get loaded on the hidden field(so that unnecessary scrolls and plain white field can be avoided)
EDIT 1
Please find the sample
http://i.stack.imgur.com/nnXrV.png
http://i.stack.imgur.com/BDQFm.png
text3.setVisibility(View.GONE);
edit3.setVisibility(View.GONE);

Put visibility of TextView and EditText to View.GONE not to View.INVISIBLE
TextView tv;
EditText et;
tv.setVisibility(View.GONE);
et.setVisibility(View.GONE);
Use as above when you want to hide the view.

this will hide your textview and edittext
TextView tv = (TextView)findviewbyId(R.id.textview1);
EditText et = (EditText)findviewbyId(R.id.edittext1);
tv.setVisibility(View.Gone);
et.setVisibility(View.Gone);

Related

how to insert textview with ImageView inside EditText in android dynamically?

I am trying to insert a textview with an imageview inside a Edittext as in below .
can anyone pls give me ideas about how to implement it or something.
thanks :)
update: the textviews in the edittext will vary dynamically
To show textview in android edittext you can try this code..
EditText your_edittext = (EditText)findViewById(R.id.text);
your_edittext.setHint("Your Text");
Now to add image you can do it like this..
Your_edittext.setCompoundDrawables(null, null, getResources().getDrawable(R.drawable.your_image), null

How to make all the TextView childs to changed the color of text?

I have a LinearLayout, mRoot, and it has two child of TextView, such as
private TextView mNameView;
private TextView mValueView;
and I also set these TextView with ColorStateList. Now, the question is when I press the mRoot, those TextView can't change the color of text.
But when I make the mRoot as the item of ListView, then when I press the item, it can change the color of text.
Can anyone help me with this?
Try setting the android:duplicateParentState attribute to true in your TextView declarations in XML.

Change new text view inside of a dialog

I built a linear layout inside of a dialog , the problem here that i want to change the TextView of this layout but i don't know how ! ,, any help ?
The same way you would do it with a normal view.
TextView text = (TextView) dialog.findViewById(R.id.TextView01);
text.setText("Hello");

How to change a textview with both addTextChangedListener and RadioButton changes

I have a textview that I have linked to an edittext box so that when it is edited, it changes my textview. I have a radiobutton used in the interpretation of the textview but it has to be selected before i edit the edittext box in question.
What I would like is for the textview to be changed when i change the radiobutton AS WELL AS when i change the edittext boxes. An example is:
I have 3 Edittext boxes and 1 RadioGroup (consisting of 2 RadioButtons [but one of the buttons is selected by default]). I have 1 Textview.
I would like it so that when all edittext boxes are filled in, the textview is changed. I also want it so that when i change the radiobutton, it will change the textview again. And then i can go back and edit any of the 3 edittext boxes and it will change the textview. At the moment, i only have 1 addTextChangedListener in use at the moment, which is on the edditext box at the bottom of the screen (in the hope the user fills all the top fields in first). But the problem is that if the user changes the topmost edittext box, it doesnt change the textview because the listener is on the bottom box.
Hope that is clear.
Add a text changed listener to all the text boxes.
This listener should be the same for all of them. It simply needs to check if the other boxes have been filled.
if(
textBox1.getText().toString() != "" &&
textBox2.getText().toString() != "" &&
textBox3.getText().toString() != "") {
//All boxes have a value, so change the TextView
....
}

How to set focus to Textview in HorizontalScrollView?

I have a dynamic array of Textview in HorizontalScrollView.
Now i want to set focus to particular Textview
How can i do this?
You can use this Code for Focus
textview[i].requestFocus();

Categories

Resources