File browser with a ListView and back button - android

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?

Related

How do I make an Android activity like shown in this image?

How do I make an Android activity like the one shown in this image.
I am asking specifically about how to make a component such as the repeat and reminder components. And also, the two tabs showing Add Event and Add Task.
I'd also like to know the name by which they are referred.
Touching Repeat, a list dialog box appears. Touching Reminder, different times can be set which can be removed by a minus sign (-) which appears beside them. The tabs cannot be slid, but they need to be clicked to go to a particular tab.
It looks like it's just a listview on top of a tabbed activity.
When you create a new Activity, you can just specify tabbed activity and Android studio takes care of creating the tabs.
Then for the items, you just use listview, unless it'll turn out to be a really long list, then a recyclerview is recommended.
Hope that helps (:

Spinner inside custom ListView freezes on returning from another activity

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.

android dependency on resource variable names

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.

Dynamically load layout in Android

My application requires 2 screens and for this I have created two different XML layout files using RelativeLayout. One layout file loads whenever I run my Activity. Now I want to load the second layout on to the same Activity , when user click on a button in OptionsMenu and also when user press Back button the first screen loads instead of exiting the application. So that i don't need to create another Intent in my application.
Ideally there should be two different activities present in your application.
You can add or remove a view component in a view but if you are looking for two completely different screens then i would suggest you to go for a new activity.
I dint get what you meant by "and also when user press Bakc button the first screen loads instead of exiting the application"
If you dont want to show the first screen just finish() the activity.
Did you try re-calling the setContentView?
Or you may prefer using the ViewFlipper,
Good example here.
I would suggest a rather simpler means.
Put both your layouts in the single XML and show/gone them appropriately as need be. I dont think u need anything more complicated :-)

Android and XML Usage

Hai,
I am developing a Puzzle in Android.
The puzzle is something like finding a number.
It contains 7 steps.
Here I use 7 xml files
Each file is meant for some operations
The 7th file displays the output.
There is a Try again button in the 7th file and when the user clicks on that button, it should call the 1st xml file and repeat the same process again.
The code for that navigation is something like:
setcontentView(R.layout.main1); where main1 is the 1st xml file.
The problem is that, the control goes to the 1st file but the processes can't be repeated.ie. the controls inside that page will be in inactive state.
Can any one give some suggestions here?
Another option would be to raise the initial Intent on the Try Again button press. This should reinitialise the application, and should have the added benefit of allowing the user to go Back to their previous result.
These are only ideas though, I'm a noob at Android development....

Categories

Resources