how do I make unfocusing keyboard to edittext when App launchs? [duplicate] - java

This question already has answers here:
How to stop EditText from gaining focus when an activity starts in Android?
(54 answers)
Closed 3 years ago.
I have edittext on my Xml layout. When the app launch, keyboard is coming and focusing to edittext. I dont want this. How can I unfocus it on Android Studio ?

set below property of your parent/Top level layout.
android:focusable="true"
android:focusableInTouchMode="true"
and Its working Nicely :)

Use this line in your activity it will hide your soft input
keyboardthis.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
Alternatively, you can use
edittext.clearFocus();

Set this following line with your activity tag in manifest
android:windowSoftInputMode="stateHidden"
or
you can set following line in oncreate method of your activity
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

Related

Android Studio Preview is not showing ListView examples

I'm new to app development, so maybe I just made an obvious mistake.
However my problem is, like I mentioned in the title, my preview is not showing the ListView examples (Picture 1 show what I want the preview to show), but when I add an ArrayList and start it on the emulator every thing is displayed correctly.
1 https://i.stack.imgur.com/w4uON.png
2 https://i.stack.imgur.com/6Hneo.png
3 https://imgur.com/sQtBpAo
4 https://imgur.com/a/moT6M4K
In your layout XML (activity_main.xml), you can add the tools:listitem attribute to the ListView to specify a layout to show in the preview. Like this...
<ListView
android:id="#+id/myListView"
android:layout_width="0dp"
android:layout_height="0dp"
tools:listitem="#layout/item_something"
... />
Just replace 'item_something' with the name of the layout you want to use for each item.
PS. When you're in 'Design' mode rather than editing the XML, look for the attributes with a small spanner icon to the left. There are other 'tools' attributes you can use for similar things.

in android after write any code to fragment java file app is closing tapped that fragment

I'm working on a Android application. My app will include bottom navigation bar with four item and toolbar with one item. In my project, when there is no code, fragments and app is working, but when i wrote a line of code such as "EditText editText=getView().findViewById(R.id.editText);" to a fragment java file, my app is closing after tapped that fragment. After erase that code line, my app is working properly. Could you help me?
You need to cast the value to EditText.
EditText editText = (EditText) getView().findViewById(R.id.editText);
This was answered already here.

Android - Not auto select an EditText field [duplicate]

This question already has answers here:
How to stop EditText from gaining focus when an activity starts in Android?
(54 answers)
Closed 7 years ago.
When I travel between Activities my app auto select the first EditText field on the screen, calling the keyboard.
There is any way to start an Activity without selecting anything by default?
You should add this to its parent layout
android:focusable="true" android:focusableInTouchMode="true"

How to stop soft keyboard appear by default in android

I am writing an android application with two EditText on the main activity. My problem is that once the main activity starts the soft keyboad automatically appears. I want the soft keyboard to appear only when the user clicks on the EditText component. How can I accomplish this?
In your activity, in your onCreate method, put the following
edittext.setFocused(false);
And then afterwards (in a different method, maybe an onClickListener for your edittext) put
edittext.setFocused(true);
Also you could put the below line in you manifest, in the the activity section, just below the android:name attribute
android:windowSoftInputMode="stateUnchanged"
Try this,
<EditText android:id="#+id/edit_text_id"
..
android:focusable="false" />
if you want to manage the inpt events , take a look on this part :
==> http://developer.android.com/guide/topics/ui/ui-events.html

Android Button Visiblity [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Problem with Image Button visibility! Android
When you start the application, the buttons should be visible for 5 seconds and then become invisible, so people will know there are buttons on the screen. For example If I have a MapActivity running, the button will be an obstruction. So I want to make it invisible. It should be visible again on touching that area or around that button area so as to trigger another activity. I tried setting visibilitiy. nextbutton.setVisibility(View.INVISIBLE) I can't make it visible onTouch() Please help me with the problem.
See your original thread which has more than enough information for you to do what you want.

Categories