Tuesday, September 21, 2010

Activity in android

      Activity is important ui unit of android application.

To start an activity from another, you have to use an intent by sending the new activity class as parameter.

e.g.
         Intent i = new Intent(this, NewActivity.class);


Next you call startActivity method

     startActivity(i);

You can pass extra data to the new actiivity by using putExtra method.


   i.putExtra( "Title",mTitle);


In the new activity, you can extract this information using getExtra methods

   Intent i = getIntent();
   String t = i.getStringExtra("Title");

      

Monday, September 20, 2010

List View - How to avoid black selected items

  Twice I faced the same problem. I had used listview. If you drag on the view it would show all the list elements.

Solution:

   In the code, use
listview.setCacheColorHint(Color.TRANSPARENT).

Your problem is solved

Simple. Isn't it?