Skip to main content

Featured

Android studio “SDK tools directory is missing”

Following 2 possible solutions will resolve this problem :  Solution1 : To fix the problem, it was required that I list the path to my corporate PAC file by using  Configure -> "Appearance and Behavior" -> System Settings -> HTTP Proxy . I selected "Automatic proxy configuration url:" Delete your  ~/.Android*  folders (losing all of your settings :/). Run Android Studio. It will show you a welcome wizard where it tries to download the SDK again (and fails due to my rubbish internet). Click the X on the wizard window. That will enable you to get to the normal welcome dialog. Go to Settings->Project Defaults->Project Structure and change the Android SDK location to the correct one. Solution 2 : To fix the problem, it was required that I list the path to my corporate PAC file by using  Configure -> "Appearance and Behavior" -> System Settings -> HTTP Proxy . I selected "Automatic proxy configuration url:...

Sample and simple ListView Code,in Android

package org.dharani.ExpandListViews;

import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;

public class ExpandableListViews_UsingAnimationActivity extends Activity {
   
    UserListAdapter adapter;
    ListView list;   
    String str[]={"ljds jasljdkljasl dl asldl lasdllasldjasljdljasl dlasl jdl jasld l asldlasdkasld klas dlaslkdklja sdkl aldj la"
            ,"las dkasld asjlkjdlasljld lasjdjklasj kljdlasjlkjdklallqjejqwj leqwkjlejlq wle klqwkle qwle lqwjl elqwjljelqwl eqw ekl qkwljel qkwl ekljqwkle lkqw ejlqwlke klqwjeqwllleqwje"
            ,"ljasldj klaskldjl asldl ask klasj kld asldl asl dlasl dldlsj"
            ,"ajldjas dljasjdljlasjld las jldjlasj ldasjd jlas daslj ldjlasjd jasljldjasl dljasjdljasjdjasljdlasjjdljasljdlasj dasj lldkslkasjd asl lasjdlasj dljas ldasljd lajs dasd asld asjdjasdlaslj kl"};
   
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       
        adapter=new UserListAdapter(this);
       
        list=(ListView)findViewById(R.id.list);
        list.setAdapter(adapter);
    }
   
   
    public class UserListAdapter extends BaseAdapter
    {       
        ViewHolder holder = null;
       
        @Override
        public int getCount() {
            int count=0;
            try {
                 count=str.length;
                 System.out.println("----lengthg--"+count);
            } catch (Exception e) {
                e.printStackTrace();
            }
            return count;
        }

        Activity context;

        public UserListAdapter(Activity context) {
            super();           
            this.context = context;
        }

         class ViewHolder {
           
             TextView textView; Button moreButton;                       
        }

        public View getView(final int position, View convertView, ViewGroup parent){
           
            View rowView = convertView;           
           
            if (rowView == null) {
               
                LayoutInflater inflater = context.getLayoutInflater();           
                rowView = inflater.inflate(R.layout.panel, null, true);
                holder = new ViewHolder();               
                holder.textView=(TextView) rowView.findViewById(R.id.value);               
                holder.moreButton=(Button) rowView.findViewById(R.id.expand);
               
                rowView.setTag(holder);
            }
            else
            {
                holder = (ViewHolder) rowView.getTag();
            }           
           
            holder.textView.setText(str[position]);
           
           
           
            return rowView;

        }

        @Override
        public long getItemId(int position) {
            return position; 
        }

        @Override
        public Object getItem(int position) {
            return str[position];
           
        }   

    }
   
   
}

Comments