Coding issues, please help...

Put your problem here if it does not fit any of the other categories.

Coding issues, please help...

Postby tv_sathish » Mon Mar 03, 2008 6:31 pm

Hi all,
Can someone clarify the following:

1. How to perform any network related activity in onCreate method of Activity class or in any other method in
Activity class for that matter? I tried doing it in a Thread, but still it failed, whereas the same thing works well
in a normal Java project (not Android project)? What is the way to do some network activity in Activity class?

2. When the activity runs, does it run in a different environment? I ask this because when I test the code in a
normal Java project, it is able to pick up a text file that a class in a referred JAR uses, if I just place the text
file within "lib" folder. But when I use it within Android, it is unable to find the text file. I do not have the
source code also to find out where the class (which is inside the referred JAR that I refer to in my Activity
class) is searching for that text file?

3. How to start with a layout and then dynamically add additional View objects to the page (something like a
AJAX page refresh)? That is, I have a default View, when I click one choice, it should show a few more View
objects (in addition to existing ones) in same page, and show a different set of objects if I select another
choice?

4. How to disable Spinner choice selection after I have selected one item in it and doing some processing in it
and do not want the user to be able to select another choice in between? How to do this in general to any View
object?

Thanks and regards,
TVP
tv_sathish
Developer
Developer
 
Posts: 29
Joined: Wed Jan 09, 2008 12:32 pm

Top

Re: Coding issues, please help...

Postby cabernet1976 » Tue Mar 04, 2008 5:22 am

Hi tv_sathish,

tv_sathish wrote:1. How to perform any network related activity in onCreate method of Activity class or in any other method in
Activity class for that matter? I tried doing it in a Thread, but still it failed, whereas the same thing works well
in a normal Java project (not Android project)? What is the way to do some network activity in Activity class?

It is better to do network operation in a separated thread, for it often cost long time and will lead main thread timeout.

tv_sathish wrote:2. When the activity runs, does it run in a different environment? I ask this because when I test the code in a
normal Java project, it is able to pick up a text file that a class in a referred JAR uses, if I just place the text
file within "lib" folder. But when I use it within Android, it is unable to find the text file. I do not have the
source code also to find out where the class (which is inside the referred JAR that I refer to in my Activity
class) is searching for that text file?

please refer to this tutorials by plusminus: http://www.anddev.org/working_with_files-t115.html

tv_sathish wrote:3. How to start with a layout and then dynamically add additional View objects to the page (something like a
AJAX page refresh)? That is, I have a default View, when I click one choice, it should show a few more View
objects (in addition to existing ones) in same page, and show a different set of objects if I select another
choice?

of course you can create view and layout by program, there are all classes. please search in anddev.org about it.

tv_sathish wrote:4. How to disable Spinner choice selection after I have selected one item in it and doing some processing in it
and do not want the user to be able to select another choice in between? How to do this in general to any View
object?

how about setEnabled(false)?
Upload2Flickr's blog: http://upload2flickr.blogspot.com
cabernet1976
Senior Developer
Senior Developer
 
Posts: 154
Joined: Fri Nov 16, 2007 2:34 am
Location: China

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google Feedfetcher and 14 guests