When I searched I got an answer but that didnt help me. Well.
Now, in my manifest file I used with that particular activity like this:
android:windowSoftInputMode="stateVisible"
It works but shows only alpha keyboard! I want actually want numeric keyboard,please.
Is there a particular EditText you want to have focus first for the numeric keyboard?
If so then try this on the relevant EditText:
XML:
<EditText
android:id="#+id/myEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="number">
<requestFocus/>
</EditText>
OR Runtime (onCreate):
EditText editText = new EditText(this);
editText.requestFocus();
editText.setInputType(InputType.TYPE_CLASS_NUMBER);
In your focused EditText add this:
android:inputType="number"
Related
I am attempting to make a textview clickable by adding an email autolink attribute to it with android:autoLink="email"but as soon as I add it, the text just disappears. What's interesting is that other combinations of text appear just fine. When typing in an email, as soon as I type the "o" in sample#gmail.com, the text just disappears. Am I doing something wrong?
My TextView
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:linksClickable="true"
android:text="sample#gmail.com"
android:clickable="true"
android:autoLink="email"
android:textColor="#54ACE6"
android:textSize="13dp" />
Try to set android:textColorLink="#color/blue" or any other color different than your background.
EditText
android:textSize="18.0sp"
android:textColor="#color/red"
android:id="#id/et_server_url"
android:layout_width="fill_parent"
android:layout_height="0.0dip"
android:layout_marginLeft="50.0dip"
android:layout_marginTop="10.0dip"
android:layout_marginRight="50.0dip"
android:text="#string/serverurl"
android:layout_weight="0.8"
android:layout_toRightOf="#id/iv_logo"
android:layout_below="#id/et_email"
android:layout_centerHorizontal="true"
android:enabled="false" />
In this code, Text is not displaying .
Note: I have to change this only in the layout. I didn't have any java files.so
try
android:background="#null"
or
android:background="#android:color/transparent"
in programmatically
setBackgroundDrawable(null);
or
setBackgroundColor(getResources().getColor(android.R.color.transparent))
I think you are using this edit text inside a RelativeLayout. So, remove this property and add height.
Remove this:-
android:layout_weight="0.8"
And Add this:-
android:layout_height="wrap_content"
You will be good to go.
And use,
EditText et_server_url = findViewById(R.id.et_server_url);
et_server_url.setEnabled(false); //To make it disabled
and
et_server_url.setEnabled(true); //to make it enabled
try to use this code
<EditText
android:id="#id/et_server_url"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/et_email"
android:layout_centerHorizontal="true"
android:layout_marginLeft="50.0dip"
android:layout_marginRight="50.0dip"
android:layout_marginTop="10.0dip"
android:layout_toRightOf="#id/iv_logo"
android:background="#drawable/background_editext"
android:fontFamily="sans-serif"
android:inputType="none"
android:paddingLeft="20.0dip"
android:paddingRight="20.0dip"
android:text="#string/serverurl"
android:textColor="#color/red"
android:textSize="18.0sp" />
you're hiding yout EditText that is why you can't see or edit it
bro your code working you can check android:text="#string/text" to android:text="text"
use hardcore string and check coz i am copy your code its working fine ...
and generally edittext use android:hint not android:text
and you can also set editable="false" in android:hint using...
check its may help you...otherwise tell me ..
Unsure of how to display text in the xml file, i have code written to output text in the java file but nothing happens when the application is run
TextView tv = (TextView) findViewById(R.id.my_text_view);
tv.setText("Welcome to the Dungeon");
*
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/my_text_view"
android:text="#string/my_text_view"/>
Use this:
<TextView android:id="#+id/my_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Example"
android:layout_gravity="center"
android:textColor="#656565"
android:textSize="20dp" />
And then setText
why are you setting text twice in xml and java, just add once as:
but whatever try to provide : fontsize, and gravity(center) of layout, either programmatically or in xml
I'm creating a list of buttons in Android with the same icon for each of them and then set the text programmatically. So my list has:
ImageView (always the same) + Text (label for the icon which I set programmatically).
How can I create a something like the icon below but where I can change text dinamically?
Thank you!
You can use android:drawableLeft attribute in the TextView. Here's the sample:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:id="#+id/textView"
android:gravity="center_vertical"
android:layout_margin="16dp"
android:drawableLeft="#drawable/ic_launcher"
/>
And the result
I would suggest you using the following
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button_text"
android:drawableLeft="#drawable/button_icon"
... />
If you are looking for more customized button, then probably you should learn more about Custom Views:
https://developer.android.com/training/custom-views/index.html
What I understand from your question is that you want to change/set the text of the button programmatically.
for this use the following code in onCreate event:
Button mybutton = (Button) findViewById(R.id.your_button_name);
mybutton.setText("Your Text Here");
I have in my layout a EditText and I don't want the user to click on it of the keyboard to appear but to be ready, I think this is something you put in the layout file but I really don't what it is.
You can add the basise <requestFocus /> on your layout (as describe here) or use the function requestFocus() of the EditText on the onCreate method of the Activity/Fragment (as describe here)
the property you are looking for is called focusable... and you need to set it true
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="phone"
android:ems="10"
android:id="#+id/PhoneNumberInput"
android:hint="Numero telefonico"
android:layout_below="#+id/textView"
android:layout_centerHorizontal="true"
android:layout_marginTop="36dp"
android:focusable="true"/>
//Hide the Keyboard
InputMethodManager imm = (InputMethodManager)getSystemService(
Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(serverURL.getWindowToken(), 0);
//Show the Keyboard
imm.showSoftInputFromInputMethod(serverURL.getWindowToken(), 0);
but under post runnable over the view.