Search in sources :

Example 21 with AdapterView

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

the class GridViewExample method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.gridview);
    final GridView gridView = (GridView) findViewById(R.id.gridview);
    final GridViewAdapter adapter = new GridViewAdapter(this);
    adapter.setMode(Attributes.Mode.Multiple);
    gridView.setAdapter(adapter);
    gridView.setSelected(false);
    gridView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            Log.e("onItemLongClick", "onItemLongClick:" + position);
            return false;
        }
    });
    gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Log.e("onItemClick", "onItemClick:" + position);
        }
    });
    gridView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

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

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
}
Also used : GridViewAdapter(com.daimajia.swipedemo.adapter.GridViewAdapter) AdapterView(android.widget.AdapterView) GridView(android.widget.GridView) GridView(android.widget.GridView) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 22 with AdapterView

use of android.widget.AdapterView 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 23 with AdapterView

use of android.widget.AdapterView 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 24 with AdapterView

use of android.widget.AdapterView in project UltimateAndroid by cymcsg.

the class SuperListViewActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.super_list_view_activity_main);
    ArrayList<String> lst = new ArrayList<String>();
    lst.add("List example");
    lst.add("Grid example");
    mAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, lst);
    mList = (SuperListview) findViewById(R.id.list);
    mList.setAdapter(mAdapter);
    mList.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent i = new Intent();
            switch(position) {
                case 0:
                    i.setClass(SuperListViewActivity.this, ListSample.class);
                    break;
                case 1:
                    i.setClass(SuperListViewActivity.this, GridSample.class);
            }
            startActivity(i);
        }
    });
}
Also used : ArrayList(java.util.ArrayList) Intent(android.content.Intent) View(android.view.View) AdapterView(android.widget.AdapterView) AdapterView(android.widget.AdapterView)

Example 25 with AdapterView

use of android.widget.AdapterView in project UltimateAndroid by cymcsg.

the class SwipeLayout method isEnabledInAdapterView.

/**
     * if working in {@link android.widget.AdapterView}, we should response {@link android.widget.Adapter}
     * isEnable(int position).
     * @return true when item is enabled, else disabled.
     */
private boolean isEnabledInAdapterView() {
    AdapterView adapterView = getAdapterView();
    boolean enable = true;
    if (adapterView != null) {
        Adapter adapter = adapterView.getAdapter();
        if (adapter != null) {
            int p = adapterView.getPositionForView(SwipeLayout.this);
            if (adapter instanceof BaseAdapter) {
                enable = ((BaseAdapter) adapter).isEnabled(p);
            } else if (adapter instanceof ListAdapter) {
                enable = ((ListAdapter) adapter).isEnabled(p);
            }
        }
    }
    return enable;
}
Also used : AdapterView(android.widget.AdapterView) Adapter(android.widget.Adapter) BaseAdapter(android.widget.BaseAdapter) ListAdapter(android.widget.ListAdapter) BaseAdapter(android.widget.BaseAdapter) ListAdapter(android.widget.ListAdapter)

Aggregations

AdapterView (android.widget.AdapterView)650 View (android.view.View)626 ListView (android.widget.ListView)393 TextView (android.widget.TextView)325 Intent (android.content.Intent)171 ImageView (android.widget.ImageView)166 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)135 ArrayAdapter (android.widget.ArrayAdapter)73 ArrayList (java.util.ArrayList)67 ViewGroup (android.view.ViewGroup)60 AbsListView (android.widget.AbsListView)57 GridView (android.widget.GridView)55 Bundle (android.os.Bundle)52 Spinner (android.widget.Spinner)49 LinearLayout (android.widget.LinearLayout)47 OnClickListener (android.view.View.OnClickListener)44 RecyclerView (android.support.v7.widget.RecyclerView)39 SuppressLint (android.annotation.SuppressLint)37 DialogInterface (android.content.DialogInterface)37 Context (android.content.Context)30