Changing the language in fragment is destroying the view - android

I have a MainActivity wherein I am inserting a fragment over it.
In fragment there is EditText, Button ,TextView , ImageView.
When i enter some text in EditText it shows the same in TextView. And when i click on profile-image default Icon(Image View) it asks us to upload image from sd card and sets that as Profile Image.
Before clicking on submit button if i go to settings and change the language to say Japanese then after coming back to my app does not refresh the same using Japanese text. And even image uploaded but not saved also disappears.
I have values-ja for the Japanese script.
I read about onConfigChanges method in Activity. I tried that also but that method is also not getting called.

I think you should read those article, then you can solve your problem
How to refresh activity after changing language (Locale) inside application
Changing Locale within the app itself

Related

Clear Focus of EditText when clicking on a button

Everyone,
I would like to achieve the following in my Android App:
I would like to create a view in which there are several input fields.
An associated toolbar contains a save button.
If I have the focus in an EditText field and then press Save, I want the value of the edit field to be taken before saving.
So far I have created a workaround where a method resetFocus() is called before saving which does the following:
if (binding.volume.hasFocus()) binding.volume.clearFocus();
Is there a clean way to implement the request without such a help method?
Thx for you help

Select picture from android gallery (not a camera picture) and user input text and save it to an app folder to be recalled in a new activity

I am trying to build an android app that on one activity "onClick" opens the native picture gallery and allows you to pick an image and store it in a folder within the app to be recalled and presented in a different activity. The same with user input text. A user inputs text in a textbox, "onClick" saves this text to be recalled later in a different activity. I have tried several different codes to make this happen and I get errors.
Any help with example code would be appreciated.

ViewPager with TextView

I have this application that is visible in the Gallery build in Android application. When I selected multiple images and press via "Share Application", the application I'm developing, the application starts and all the images selected are displayed in ViewPager to swipe between them.
On each page, I have an ImageView, TextViewandEditText. TheImageViewto display the image. TheTextViewto set the date (using date picker) andEditText` to set the title.
The problem is when i set the date or title on a certain and swipe to the next then re-swipe back the information i set is erased.
I want the information to be saved not wiped or edited due to a change on the next pages.
How can I do that?
I have the codes if anyone would like to see.

Android: Button representing "get my position!"

I have a EditBox, and on right side of this EditBox I wan't to put a Button representing "Get My Position".
User clicks on this button, and my application get his position and fills EditBox with it.
I found a Compass and added on a ImageButton, but I don't know if this really represent the idea.
Anyone knows a better button to represent "Get My Position"?
Thanks
Your Button looks ok, and will be recognized by most users. If you want to get the System-default (the picture of the Drawalbe may differ on roms from HTC, Samsung Motorola etc) you can get it with
getResources.getDrawable(android.R.drawable.ic_menu_location)
Always check for non-Null here. You can download the standart Android location Button here, (ic_menu_location), as a fallback, if the getDrawable() call fails
I used a 'globe' in my application. If the EditBox is blank until the user requests their location, why not use the put some default text inside it requesting the user to click the button?

How is my EditText content being saved?

I created a simple app that has nothing except an EditText element. When I run the app, I type text into the element and then press Ctrl-F11 to change the emulator's orientation. I've added logging information to make sure that the activity gets destroyed and re-created when I change orientation. I haven't added any code to save the text in the EditText element and yet, after the change of orientation, the text that I typed stays in the EditText element. What mechanism in Android is saving and then restoring the element's text (is it savedInstanceState) and how can I see for myself the details of this saving operation?
onSaveInstanceState()/onRestoreInstanceState() along with unique widget IDs. Some links that utilize:
Saving Android Activity state using Save Instance State
http://groups.google.com/group/android-developers/browse_thread/thread/5d7fd8da11c8e971

Categories

Resources