I have very strange issues in my application.
I added a layout file with name add_new_item and i got an exception.
I was not even setting this xml file as content in any activity. And the exception was coming in a library function which was not touched. So while trying to find the root cause, i just tried to renaming the file to a name like "data_entry_form" and to the exception was gone !
After that again i am facing a strange similar issuse. I have a button with image name "add_new_itm". I have a layout with 4 buttons one of which is this button. After setting this layout if i click any of those buttons to reach another activity, change the phone orientation and comeback to this activity with 4 buttons and again press any of the button then wahtever layout is displayed, it has "add_new_item" image as background.
ie layout with 4 buttons ( 4th one is add_new_item ) -> press button 1 take to new screen -> rotate phone-> comeback to layout with 4 buttons -> press button 1 again -> the screen will have add_new_item image as background occupying complete screen.
Now i tried just renaming the image, the button, and everything works fine.
Can you please explain this strange behaviour
These things probably happen because the fact that if you're using a library for your project, which contains layout files, the names of your layout files and the library layouts should not overlap. The compiler generates a single R.java file for both your and library layouts, and it won't be able to do it if the files have the same names. Hope this helps.
Related
In order to make things clean for you to understand i recorded a video
The problem is that when i'm adding a Tab Layout inside another layout everything that appears in the blueprint becomes a dot in the upper left corner, leaving me with no other choice but to edit the xml itself in order to create the UI. This also happens sometimes when I add multiple nested layouts.
I'm searching like a week until now but still i can't understand why is this happening.
can someone help me find the refresh layout button which was there before studio 2.2 to refresh the layout changes?
Have searched every where but cannot find it.The problem is sometimes drawables are not refreshed and reflected in the preview window.
It's pretty simple to refresh.
Click on the preview screen, make sure that the preview window has the focus, and press R. It should display the progress in the top-right corner while refreshing.
If it doesn't work for any reason, switch to the design tab and press R. It refreshes the layout instantly.
I think it is a small bug, but I find a hack solution to resolve the problem.
You can change a resource id to a wrong name. For example, you have a resource named ic_launcher. When you input ic_launcher1, you can find the interface like this:
Next, click the refresh link (sometimes, it says 'clear cache').
I tried changing the orientation, but it does not work when I replace an existing image file.
Toggle the Orientation button in Editor, it is refreshing the changes.
Can't seem to find the refresh layout button too, it's as if it is deliberately removed.
However, I found a temporary refresh layout solution: On the screen orientation button, click the dropdown and then change the Night Mode. See this page for reference on where to find the screen orientation button. Hope this helps.
Close edited layout file and reopen.
You can do this with following shortcuts:
Ctrl+F4 (close tab)
Ctrl+Shift+E (open Recently edited files)
Enter
(select recent file to open, your layout file should be already
highlighted if edited last)
In my android app I have 3 buttons(suppose A,B and C). But whenever i try to move button B anywhere on the screen i get run time XML error.(no compile time error)
If i put it back to its original position it works fine.
Thanks.
I have one multiline textfield that is only visible when i click button A.
I think whenever i move button B this textfield also moves with it and whenever i move button B more close to the bottom i get this error.
If this is the case then is there any way to remove this dependency?
Seems you are using the graphical builder with ADT. After you move your buttons just give a look at the xml structure if the syntax is correct after the you have moved the buttons. There must be some syntax error causing the runtime XML error.
Also prefer editing the xml than using Graphic Builder for positioning after you have dropped the required elements in the layout.
I am working on a simple file explorer using android os.
I get the whole directory structure like filesize, filenames, directory name via a json object and put them in a list view. On 1) you can see, what I finally want to do.
The problem is, that the items have a complete other style like the back botton, so I may have to deal with two list views (one for the back button in every sub directory and one for the items like the 2nd variant in my picture). But having two listviews, the first one should resize in the root directory, so that it fits in the height like the version with a back button.
Do you have any ideas? I hope you unterstand, want I want.
1]: http://www.basepic.com/2014/Mar/13/97965279.png
WOuldn't it be better if you just add a button with the visibility GONE. And only make it visible on the top if you want to show the back button else just leave it hidden? Why a seperate listview for just one button?
Hello all here is my problem.
My app's listview (which is inside a tab widget) contains various types of rows. I have had many problems setting this up and here is another 1. Please see here for the code, which basically remains the same.
I use another activity (a custom implemented ES file explorer) which is a filebrowser dialog to open a file. The data from the file is sent to the listview.
When it shows the list and I click on the spinner the screen darkens and freezes. If I press the back button the darkening disappears, the listview becomes clickable but the spinner still is not. The only way out is if I flip to another tab widget and back again (there are 2 separate ones) the spinner will work again.
I should say that the spinner works just fine if I do not load files from the other activity.
So I guess in other words there is a problem of focus or something when switching and killing activities.
I hope you can help.
EDIT
after some more trying, sometimes after loading the file from the browser it will return to a black screen where the listview is there but not visible.
eg you can click on it and the editor opens.
Hi well again it took ages but here was the problem.
the custom listview had
this.setDescendantFocusability(FOCUS_BEFORE_DESCENDANTS);
set
so all I had to do was set
holder.techniquespinner.setDescendantFocusability(parent.FOCUS_BEFORE_DESCENDANTS);
for the spinner and voila; I haven't tried but it should probably go in the xml file.
Thanks to anybody who looked.
EDIT
Crap I spoke to soon. It still doesn't work.
There is 2 tabwidgets inside a flipper.
If returning from the browser to the tab where it left WITHOUT flipping the flipper it works.
Flip once, back again and then to the browser does not work.
I'm not even sure what code to post. It is quite complex.
FINAL EDIT
This is how I fixed it.
flipper.showNext();
and then back again.
It somehow refreshes the view brings it back to focus and useable again.
It isn't pretty but it works.