Search in sources :

Example 21 with ListView

use of android.widget.ListView in project AndroidSwipeLayout by daimajia.

the class ListViewExample method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.listview);
    mListView = (ListView) findViewById(R.id.listview);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        ActionBar actionBar = getActionBar();
        if (actionBar != null) {
            actionBar.setTitle("ListView");
        }
    }
    /**
         * The following comment is the sample usage of ArraySwipeAdapter.
         */
    //        String[] adapterData = new String[]{"Activity", "Service", "Content Provider", "Intent", "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient",
    //                "DDMS", "Android Studio", "Fragment", "Loader", "Activity", "Service", "Content Provider", "Intent",
    //                "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient", "Activity", "Service", "Content Provider", "Intent",
    //                "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient"};
    //        mListView.setAdapter(new ArraySwipeAdapterSample<String>(this, R.layout.listview_item, R.id.position, adapterData));
    mAdapter = new ListViewAdapter(this);
    mListView.setAdapter(mAdapter);
    mAdapter.setMode(Attributes.Mode.Single);
    mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            ((SwipeLayout) (mListView.getChildAt(position - mListView.getFirstVisiblePosition()))).open(true);
        }
    });
    mListView.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            Log.e("ListView", "OnTouch");
            return false;
        }
    });
    mListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            Toast.makeText(mContext, "OnItemLongClickListener", Toast.LENGTH_SHORT).show();
            return true;
        }
    });
    mListView.setOnScrollListener(new AbsListView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
            Log.e("ListView", "onScrollStateChanged");
        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
        }
    });
    mListView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            Log.e("ListView", "onItemSelected:" + position);
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            Log.e("ListView", "onNothingSelected:");
        }
    });
}
Also used : AbsListView(android.widget.AbsListView) AbsListView(android.widget.AbsListView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) MotionEvent(android.view.MotionEvent) ListViewAdapter(com.daimajia.swipedemo.adapter.ListViewAdapter) AdapterView(android.widget.AdapterView) ActionBar(android.app.ActionBar)

Example 22 with ListView

use of android.widget.ListView in project AndroidViewAnimations by daimajia.

the class MyActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_my);
    mListView = (ListView) findViewById(R.id.list_items);
    mTarget = findViewById(R.id.hello_world);
    mAdapter = new EffectAdapter(this);
    mListView.setAdapter(mAdapter);
    mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (rope != null) {
                rope.stop(true);
            }
            Techniques technique = (Techniques) view.getTag();
            rope = YoYo.with(technique).duration(1200).repeat(YoYo.INFINITE).pivot(YoYo.CENTER_PIVOT, YoYo.CENTER_PIVOT).interpolate(new AccelerateDecelerateInterpolator()).withListener(new Animator.AnimatorListener() {

                @Override
                public void onAnimationStart(Animator animation) {
                }

                @Override
                public void onAnimationEnd(Animator animation) {
                }

                @Override
                public void onAnimationCancel(Animator animation) {
                    Toast.makeText(MyActivity.this, "canceled previous animation", Toast.LENGTH_SHORT).show();
                }

                @Override
                public void onAnimationRepeat(Animator animation) {
                }
            }).playOn(mTarget);
        }
    });
    findViewById(R.id.hello_world).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (rope != null) {
                rope.stop(true);
            }
        }
    });
}
Also used : Techniques(com.daimajia.androidanimations.library.Techniques) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) Animator(android.animation.Animator) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) AdapterView(android.widget.AdapterView)

Example 23 with ListView

use of android.widget.ListView in project android-app by eoecn.

the class UserCollectListFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreateView(inflater, container, savedInstanceState);
    mContext = inflater.getContext();
    View view = inflater.inflate(R.layout.user_collect_list, null);
    mlv = (ListView) view.findViewById(R.id.user_listview_collect);
    mlist = new ArrayList<Map<String, Object>>();
    getData();
    mAdapter = new SimpleAdapter(inflater.getContext(), mlist, R.layout.user_collect_list_item, new String[] { "name", "content" }, new int[] { R.id.user_textview_collectTitle, R.id.user_textview_collectContent });
    mlv.setAdapter(mAdapter);
    mlv.setOnItemClickListener(this);
    return view;
}
Also used : SimpleAdapter(android.widget.SimpleAdapter) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) HashMap(java.util.HashMap) Map(java.util.Map)

Example 24 with ListView

use of android.widget.ListView in project yield-layout by evant.

the class ListExampleFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ListView listView = (ListView) view.findViewById(R.id.list);
    listView.setAdapter(new MyAdapter());
}
Also used : ListView(android.widget.ListView)

Example 25 with ListView

use of android.widget.ListView in project android_frameworks_base by ParanoidAndroid.

the class ChooseAccountActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mAccounts = getIntent().getParcelableArrayExtra(AccountManager.KEY_ACCOUNTS);
    mAccountManagerResponse = getIntent().getParcelableExtra(AccountManager.KEY_ACCOUNT_MANAGER_RESPONSE);
    // KEY_ACCOUNTS is a required parameter
    if (mAccounts == null) {
        setResult(RESULT_CANCELED);
        finish();
        return;
    }
    getAuthDescriptions();
    AccountInfo[] mAccountInfos = new AccountInfo[mAccounts.length];
    for (int i = 0; i < mAccounts.length; i++) {
        mAccountInfos[i] = new AccountInfo(((Account) mAccounts[i]).name, getDrawableForType(((Account) mAccounts[i]).type));
    }
    setContentView(R.layout.choose_account);
    // Setup the list
    ListView list = (ListView) findViewById(android.R.id.list);
    // Use an existing ListAdapter that will map an array of strings to TextViews
    list.setAdapter(new AccountArrayAdapter(this, android.R.layout.simple_list_item_1, mAccountInfos));
    list.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    list.setTextFilterEnabled(true);
    list.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            onListItemClick((ListView) parent, v, position, id);
        }
    });
}
Also used : ListView(android.widget.ListView) AdapterView(android.widget.AdapterView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView)

Aggregations

ListView (android.widget.ListView)1104 View (android.view.View)714 AdapterView (android.widget.AdapterView)425 TextView (android.widget.TextView)371 ImageView (android.widget.ImageView)163 Intent (android.content.Intent)144 AbsListView (android.widget.AbsListView)134 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)93 ArrayAdapter (android.widget.ArrayAdapter)93 ArrayList (java.util.ArrayList)80 ViewGroup (android.view.ViewGroup)70 ListAdapter (android.widget.ListAdapter)70 OnClickListener (android.view.View.OnClickListener)65 LayoutInflater (android.view.LayoutInflater)59 Bundle (android.os.Bundle)57 Button (android.widget.Button)55 LinearLayout (android.widget.LinearLayout)47 SuppressLint (android.annotation.SuppressLint)34 DialogInterface (android.content.DialogInterface)32 ScrollView (android.widget.ScrollView)31