reset password
Author Message
aligh1979
Posts: 121
Posted 10:22 Jan 26, 2012 |

I am trying to start lab 2 and make some basic looking application but I am stuck and do not know how exactly start .

1. one of the first thing to say is that even my computer camera is OK and working and I am able to capture photo with other program , the Android emulator (2.2 or 4.03) are not able to open the camera App , say it is not able to open it. is there any suggestion to fix this?

2. I was just doing little changes like button an picture and some of them made my program crashed , and after that they are a bunch of files like Thumb.db and main.out.xml are created and until I do not delete these files , the program wont run again.

3.under "res" there are three drawable folders , drawable.hdi , .mdpi and idpi , what is the difference between them?

4.
I tried to change the regular android green martian logo under the drawable folder with my own , after getting errors (explained in question 2 above) , it seemed the image had to be PNG and I only put it under the first drawable folder (hdpi) and it worked . although it shows fine when I test the App , on main.xml graphic view , it is off bigger and unusual looking and causing the string title to squeeze, but again it shows fine when the actual is running.

5.I wanted to use table layout and I expected to get some grid line layout that let me put and drop the buttons or something else into the right place... but such things does not happen and it gets more confusing.

6.although there are many challenges that I am facing to make something according to what I have in my mind - like how to draw an imaginary line on the screen , how to show a temporary square on the screen- I keep them to ask towards the end of the class since it seems very advanced to ask.

my Java Gui is amateur , but if I really want to do something I can always google and search and find something , but it seems even I do so , I am not able to use those code directly right? (since they use different libraries) . the other thing is that since we are creating those Gui component by XML (not java hard code) , I absolutely have no idea how to extend the code and how to make a button do something. as we had in our lecture last time , I understood that in order to make a button do something for instance , we need to create an intent , well there is no default intent made ready in that panel to pick and attach (even if there is , I do not know where ) .

I want to make my button do some basic action and open a photo (guide me to the photos saved in the camera to choose and show the photo on the screen).

Do you think you can guide me (us) for this here?

 

Thanks upfront.

mhajianpour
Posts: 20
Posted 00:23 Jan 27, 2012 |

1. There's actually no native way to deal with the camera in the Android emulator. There are 3rd party applications that help you do it, but nothing that is built-in to the emulator. Here's one that works decently: http://www.tomgibara.com/android/camera-source

2. I need to see what you did. Thumb.db is a Windows specific file not related to Android. If you can recreate it in class we can see what went wrong.

3. These folders basically translate to screen pixel density folders. Depending on the device your application is running on, you will want to put different sized/quality pictures to make your application look more attractive on the device it's running. For now, you can get away with just having a single drawable folder. The different folders basically are low dpi, medium dpi, high dpi. DPI is dots per inch which basically is the screen pixel density. 

4. I will have to see what you were doing to comment on this. What you see in the screen design should translate over to the emulator. 

5. It's a bit easier to drop your components onto the layout hierarchy on the right side view and use the view to see how the layout actually looks instead of dropping directly onto the layout. As you get more acquainted with the xml-based gui, you'll start creating your components in the xml. 

6. We'll talk about drawing directly onto the screen and dealing with a drawable canvas at some point throughout the course. It is a bit more involved.

We'll talk about dealing with actions and gui in general a lot more as the class progresses. You'll need to search specifically for Android gui development. If you do Java gui, you'll get a lot more information on Swing than on Android. Actions are handled very similarly to actions in traditional Java guis.

 

1. In your onCreate method you can create a button reference to a button that you have dropped onto the gui layout. You can set the ID for this button in the component properties.
2. Button bStart = (Button)findViewById(R.id.bStart);  //bStart is the name of the button (ID)
     bStart.setOnClickListener(this); //In my class, I have implemented the onClickListener interface
3. In the onClick method execute what you want when the button is clicked.
4. public void onClick(View v) {/* code here */ }

 
Hope that helps.
 
--
Mahan Hajianpour
Last edited by mhajianpour at 00:24 Jan 27, 2012.
aligh1979
Posts: 121
Posted 08:50 Jan 27, 2012 |

Thank you.

is there a way to do this in an anonymous way , since we can not implement more than one interface.

other than that I am not still sure what code will open up the android picture gallery (photos taken by camera or saved there...)

one more thing that , is whatever code that I put under  "public void onClick(View v) {/* code here */ }" , like an intent , or another way to say , aren't we required to somehow specify the intent for this?

last thing that I experimentally created another activity , and have put the  "super.onCreate(savedInstanceState);"  and
        "setContentView(R.layout.main);"  lines there too , so I believe we should have two activities now , right ?  but I still see only the first page/view and I don't know if I could switch to the second one or how to start that parallel (if it haven't started yet) , plus  how we can modify main.xml for different activities , since there is only one main.xml file ?

aligh1979
Posts: 121
Posted 09:33 Jan 31, 2012 |

Why we are having two parameters for a new intent ? is it sating that this intent is going to be used across these 2 classes?

"Intent mainIntent = new Intent(EnterName.this, HelloWorld2Activity.class);

aligh1979
Posts: 121
Posted 09:36 Jan 31, 2012 |

If we have an Intent this is the way to start an activity ?

"EnterName.this.startActivity(mainIntent); "

 

mhajianpour
Posts: 20
Posted 20:23 Feb 03, 2012 |

1. No. The first argument is for the context you're switching from (which would be the current Activity). The second argument is the object (Activity) you will start when you start the Intent.

2. Yes.

--

Mahan Hajianpour

anuj.nagar
Posts: 1
Posted 14:34 Feb 04, 2012 |

Is there an easy way to disable auto suggestions in an EditText view? I've found a way to do it via Java code but the android:inputType = "textNoSuggestions" doesn't quite seem to work in the XML.

mhajianpour
Posts: 20
Posted 22:05 Feb 05, 2012 |

That Android Properties for EditText might only be available in higher SDK versions (not sure what version you're building towards). 

Try this: android:inputType="textFilter"

It should do what you want.

--

Mahan Hajianpour