This is my keyboard zoomin view when i click the edit text.
Problem is:
It is way too big only one small strip of edit text is enough.
Keyboard sometimes floating sometimes docking dont know what controls it.
No need of that finish button and green line
What is the callback function once the input in done
This is the method request soft keyboard popup
public void editText(){
Toast.makeText(mContext, "Editing Text",Toast.LENGTH_SHORT).show();
InputMethodManager imm = (InputMethodManager)getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
mEditText.setVisibility(VISIBLE);
mEditText.requestFocus();
mEditText.setText(mText);
imm.showSoftInput(editText, InputMethodManager.SHOW_FORCED);
}
Properties of edit text
<EditText
android:id="#+id/edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:hint="annotation text"
android:inputType="text"
android:textSize="14sp"
android:visibility="gone"/>
It a default layout when you change your device orientation to landscape.
Add
android:imeOptions="flagNoExtractUi|flagNoFullscreen"
to disable the fullscreen editing view
<EditText
android:id="#+id/edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:imeOptions="flagNoExtractUi|flagNoFullscreen"
android:hint="annotation text"
android:inputType="text"
android:textSize="14sp"/>
flagNoExtractUi Used to specify that the IME does not need to show its extracted text UI. For input methods that may be fullscreen,
often when in landscape mode, this allows them to be smaller and let
part of the application be shown behind. Though there will likely be
limited access to the application available from the user, it can make
the experience of a (mostly) fullscreen IME less jarring. Note that
when this flag is specified the IME may not be set up to be able to
display text, so it should only be used in situations where this is
not needed.
flagNoFullscreen Used to request that the IME never go into fullscreen mode. Applications need to be aware that the flag is not a
guarantee, and not all IMEs will respect it.
Related
Im having trouble undestanding what is happening here.
If I don't mess with "setFocusable" on EditText it works like I excpect (when you click on it the keyboard pops up and you can edit it as normal), if I set it to true it also works like before:
holder.editTextExercise.setFocusable(true);
But if I set it to false, and than back to true, I can no longer see a keyboard pop up, so I can't edit it
holder.editTextExercise.setFocusable(false);
holder.editTextExercise.setFocusable(true);
Here is the EditText
<EditText
android:id="#+id/recyclerExercise"
android:layout_width="0sp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:textColor="#color/grey"
android:backgroundTint="#color/grey"
android:text="#string/app_name"
android:textSize="25sp"/>
Im putting different items with EditTexts in the recycler and sometimes I want to change them so they can/can't be editable.
What is going on here?
Instead of
holder.editTextExercise.setFocusable(false);
holder.editTextExercise.setFocusable(true);
Try
holder.editTextExercise.setEnabled(false);
holder.editTextExercise.setEnabled(true);
I want my app to provide a function to add a button like described by Avadhani Y in How to create Button Dynamically in android?
I copied this code and the button appears when I press the +-symbol but it isn't permanent. When I close the app and open it again, the button disappears.
For a minimal working example I
created a Blank Android Application Project set up by Eclipse
added part of the method described in How to create Button Dynamically in android? to MainActivity.java (The second case with the minusbutton generates several error messages, so I left it out.):
public void onClick(View v){
switch(v.getId()){
case (R.id.plusbutton):
Button myButton = new Button(this);
myButton.setText("Add Me");
LinearLayout ll = (LinearLayout)findViewById(R.id.buttonlayout);
LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
ll.addView(myButton, lp);
break;
}
}
imported the necessary packages. Actually I'm not sure whether I chose the right one for the line with the LayoutParams - eclipse listed several packages - I chose android.view.ViewGroup.LayoutParams
changed the activity_main.xml file to the one below.
added some strings to the strings.xml file
My activity_main.xml file:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/buttonlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.button_test.MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hello_world" />
<Button
android:id="#+id/plusbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onClick"
android:text="#string/plus" />
</LinearLayout>
The problem is that you can't save to resources such as layout files at runtime. So, your options (AFAIK) are to save the params and attributes of the Button into a db or other persistent storage then check at startup each time to recreate the Button. This would be very cumbersome, I would imagine, and very error-prone if not careful.
Another option, if there is a finite number of Buttons available to be made, is to simply create them in your xml then use the visibility attribute to change from gone/invisible to visible when needed.
Android is "stateless" - in other words, unless you "save" changes, they are discarded. What you need to do is include a way to persist any changes that you expect to survive beyond the user's immediate interaction with your app. Also, you should assume that any change might be discarded immediately afterward - in other words, don't "wait" to save changes. If the user's phone rings, your app might go to the background and get killed before onPause or onStop or onDestroy are ever called.
Look into saving a "flag" for the visibility of the button into SharedPreferences and then read the flag in onCreate or onStart or onResume. It's likely you could use any of these, but you will find that sometimes one or another works best (or one doesn't work right at all).
I would like to have a EditText in my Android app that you can not see, however you can select and type text into. In other words I would like it so that it can not be seen at all however other than that it behaves completely normally.
Another option is to have an image or button on the screen which the user presses to enter text into the EditText which is hidden behind another EditText.
Thanks for the help, however it is looking more likely that I will have to use the second option. To elaborate on it, for example I have a TextView that says 'Welcome'. I would like the user to be able to click on this text to bring up the keyboard and edit in the EditText field. The reason for having the EditText field hidden behind another is to cover up the cursor while making it seem the user is typing the text which appears on the screen.
If you would like to make the EditText fully invisible (even what the user types in) , but still be able to retrieve the entered data through myEditText.getText().toString(),
you could add:
android:textColor="#android:color/transparent"
android:background="#00000000"
android:cursorVisible="false"
if I'm getting you correctly. Here is how you can accomplish the first option of yours by setting the background to transparent and cursor visibility to false.
To check this you have to click at the center of screen.
e.g. code snippet:
<EditText
android:id="#+id/eT1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="#00000000"
android:cursorVisible="false"
android:ems="10" >
</EditText>
Set transparent Background to EditText.
android:background="#00000000"
Sorry but I didn't understand your another question.
I want to have a "comments" button on my Android e-reader app that displays the number of comments currently posted inside the icon... so basically I want a comment bubble with a number inside it.
I could have multiple drawables, each being the bubble with a different number inside of it, and use a switch statement to choose which one to load each time based on the int number_of_comments field of the element being displayed. This approach seems a little wasteful though, and in any case I have a feeling there's a more elegant way to do it.
Any ideas?
You can do better. You can have a textview on top of the image view and keep updating its value everytime a new comment is added. You can define the overlap in xml like below and adjust your code logic accordingly to increase the comment count. For now I have just set up a dummy text Hello to show on top of the ImageView. You can add your comment count using the TextView's setText method.
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/relativelayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="#+id/myImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/myImageSouce" />
<TextView
android:id="#+id/myImageViewText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/myImageView"
android:layout_alignTop="#+id/myImageView"
android:layout_alignRight="#+id/myImageView"
android:layout_alignBottom="#+id/myImageView"
android:layout_margin="1dp"
android:gravity="center"
android:text="Hello"
android:textColor="#000000" />
</RelativeLayout>
Hope this helps...
check out this 3rd party created widget
Android ViewBadger
You can use it to create the little number bubbles that you are looking for I think. This gives you the benefit of not having modify your layouts so much to achieve what you are trying to get.
Here is the sample code to apply a "badge"
View target = findViewById(R.id.target_view);
BadgeView badge = new BadgeView(this, target);
badge.setText("1");
badge.show();
I have an issue with a virtual keyboard.
This Soft Keyboard Covers Data Fields - and can't See what's going on.
I want to use this soft keypad and at the same time it should not become a problem to use data fields.
So how can I manage the data fields in such cases?
Encase the layout that you already have set up within a ScrollView. This will allow the content to scroll when the software keyboard shows. Keep in mind a ScrollView has to be formatted as such.
<Scrollview android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content">
<!-- Your content -->
</LinearLayout>
</ScrollView>
You may also consider setting the following attribute on your Activity in the Android Manifest to further specify the behavior.
From here (http://developer.android.com/guide/topics/manifest/activity-element.html):
android:windowSoftInputMode=["stateUnspecified",
"stateUnchanged", "stateHidden",
"stateAlwaysHidden", "stateVisible",
"stateAlwaysVisible", "adjustUnspecified",
"adjustResize", "adjustPan"]
I find that adjustResize works better for applications contained in ScrollViews in my particular case.