Pages

Friday 3 February 2012

How to change color of alternative row in listview in android?

Hope this will help you...:-)
if(postion%2==0)
            {
                convertView.setBackgroundColor(Color.parseColor("#A9BCF5"));
            }else
            {
                convertView.setBackgroundColor(Color.parseColor("#ffffff"));
            }

Thanks
V.k.Hooda

How to use listview using custom Adapter in Android?

Hope this will help you..:-)

ListView list;
protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
list = (ListView) findViewById(R.id.list);

list.setAdapter(new customadapter());
}

class customadapter extends BaseAdapter{

        public int getCount() {
            // TODO Auto-generated method stub
            return arraylist.size();
        }

        public Object getItem(int position) {
            // TODO Auto-generated method stub
            return position;
        }

        public long getItemId(int position) {
            // TODO Auto-generated method stub
            return position;
        }

        public View getView(int postion, View convertView, ViewGroup parent) {
            // TODO Auto-generated method stub
            ViewHolder holder = null;
            LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
            if (convertView == null) {
                convertView = inflater.inflate(R.layout.readsggs_row,
                        null);
                holder = new ViewHolder();
            }else
            {
              
                    holder = (ViewHolder) convertView.getTag();
              
            }
                //for (i = 0; i < DatabaseMethods.sggsbmid.size(); i++) {
            convertView.setTag(holder);
            if(postion%2==0)
            {
                convertView.setBackgroundColor(Color.parseColor("#A9BCF5"));
            }else
            {
                convertView.setBackgroundColor(Color.parseColor("#ffffff"));
            }
            holder.textview = (TextView) convertView
                        .findViewById(R.id.text);

           <///Like this text view you can use any view that you need////>

            return convertView;
        }
        class ViewHolder {
            TextView textview;
        }
    }


Thanks
V.k.Hooda

Tuesday 31 January 2012

How to change textcolor of tab text in Android

TabHost tabs = (TabHost)findViewById(R.id.TabHost01);
        tabs.setup(getLocalActivityManager());
       
       
        TabHost.TabSpec search = tabs.newTabSpec("tag1");
        search.setContent(new Intent(this,Searchgurbani.class));
        search.setIndicator("Find Me");
        tabs.addTab(search);
       
        TabHost.TabSpec pref = tabs.newTabSpec("tag5");
        pref.setContent(new Intent(this,Preferencegurbani.class));
        pref.setIndicator("Settings");
        tabs.addTab(pref);
       
        TabHost.TabSpec favorite = tabs.newTabSpec("tag6");
        favorite.setContent(new Intent(this,Favroite.class));
        favorite.setIndicator("BookMark");
        tabs.addTab(favorite);
       
        for(int i=0;i<tabs.getTabWidget().getChildCount();i++)
        {
            TextView tv = (TextView) tabs.getTabWidget().getChildAt(i).findViewById(android.R.id.title);
            tv.setTextColor(Color.parseColor("#ffffff"));
        }

Monday 30 January 2012

Send MMS using Intent In Android

Uri mmsUri = Uri.parse("content://media/external/images/media/--"); Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra("body", "ITS FOR YOU");
intent.putExtra(Intent.EXTRA_STREAM, mmsUri); 
intent.setType("image/png"); 
startActivity(intent);