Search in sources :

Example 11 with AdapterView

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

the class SwipeLayout method performAdapterViewItemLongClick.

private boolean performAdapterViewItemLongClick() {
    if (getOpenStatus() != Status.Close)
        return false;
    ViewParent t = getParent();
    if (t instanceof AdapterView) {
        AdapterView view = (AdapterView) t;
        int p = view.getPositionForView(SwipeLayout.this);
        if (p == AdapterView.INVALID_POSITION)
            return false;
        long vId = view.getItemIdAtPosition(p);
        boolean handled = false;
        try {
            Method m = AbsListView.class.getDeclaredMethod("performLongPress", View.class, int.class, long.class);
            m.setAccessible(true);
            handled = (boolean) m.invoke(view, SwipeLayout.this, p, vId);
        } catch (Exception e) {
            e.printStackTrace();
            if (view.getOnItemLongClickListener() != null) {
                handled = view.getOnItemLongClickListener().onItemLongClick(view, SwipeLayout.this, p, vId);
            }
            if (handled) {
                view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
            }
        }
        return handled;
    }
    return false;
}
Also used : ViewParent(android.view.ViewParent) AdapterView(android.widget.AdapterView) Method(java.lang.reflect.Method)

Example 12 with AdapterView

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

the class SwipeLayout method performAdapterViewItemClick.

private void performAdapterViewItemClick() {
    if (getOpenStatus() != Status.Close)
        return;
    ViewParent t = getParent();
    if (t instanceof AdapterView) {
        AdapterView view = (AdapterView) t;
        int p = view.getPositionForView(SwipeLayout.this);
        if (p != AdapterView.INVALID_POSITION) {
            view.performItemClick(view.getChildAt(p - view.getFirstVisiblePosition()), p, view.getAdapter().getItemId(p));
        }
    }
}
Also used : ViewParent(android.view.ViewParent) AdapterView(android.widget.AdapterView)

Example 13 with AdapterView

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

the class MyActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_my);
    mEasingList = (ListView) findViewById(R.id.easing_list);
    mAdapter = new EasingAdapter(this);
    mEasingList.setAdapter(mAdapter);
    mTarget = findViewById(R.id.target);
    mHistory = (DrawView) findViewById(R.id.history);
    mEasingList.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            mHistory.clear();
            Skill s = (Skill) view.getTag();
            AnimatorSet set = new AnimatorSet();
            mTarget.setTranslationX(0);
            mTarget.setTranslationY(0);
            set.playTogether(Glider.glide(s, 1200, ObjectAnimator.ofFloat(mTarget, "translationY", 0, dipToPixels(MyActivity.this, -(160 - 3))), new BaseEasingMethod.EasingListener() {

                @Override
                public void on(float time, float value, float start, float end, float duration) {
                    mHistory.drawPoint(time, duration, value - dipToPixels(MyActivity.this, 60));
                }
            }));
            set.setDuration(1200);
            set.start();
        }
    });
}
Also used : BaseEasingMethod(com.daimajia.easing.BaseEasingMethod) AnimatorSet(android.animation.AnimatorSet) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) Skill(com.daimajia.easing.Skill) AdapterView(android.widget.AdapterView)

Example 14 with AdapterView

use of android.widget.AdapterView in project TextureViewDemo by dalinaum.

the class ListActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    final Demo[] demos = { new Demo("Camera", CameraActivity.class), new Demo("GL Triangle", GLTriangleActivity.class), new Demo("Canvas", CanvasActivity.class), new Demo("Canvas2", Canvas2Activity.class), new Demo("Demo repository", null) };
    super.onCreate(savedInstanceState);
    final ListView listView = new ListView(this);
    listView.setAdapter(new ArrayAdapter<Demo>(this, R.layout.list, R.id.activity_name, demos) {

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            final LinearLayout view = (LinearLayout) super.getView(position, convertView, parent);
            final Demo demo = getItem(position);
            final TextView activityClass = (TextView) view.findViewById(R.id.activity_class);
            if (demo.classType != null) {
                activityClass.setText(demo.classType.toString());
            } else {
                activityClass.setText("");
            }
            return view;
        }
    });
    listView.setClickable(true);
    listView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            final Demo demo = (Demo) parent.getAdapter().getItem(position);
            final Intent intent;
            if (demo.classType != null) {
                intent = new Intent(ListActivity.this, demo.classType);
            } else {
                final String url = "https://github.com/dalinaum/textureviewdemo";
                intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(url));
            }
            startActivity(intent);
        }
    });
    setContentView(listView);
}
Also used : OnItemClickListener(android.widget.AdapterView.OnItemClickListener) ViewGroup(android.view.ViewGroup) Intent(android.content.Intent) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) ListView(android.widget.ListView) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout)

Example 15 with AdapterView

use of android.widget.AdapterView in project V2HOT by djyde.

the class TitleListActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_title_list);
    final SwipeRefreshLayout swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.pull);
    final ArrayAdapter<Topic> topicsAdapter = new ArrayAdapter<Topic>(this, 0) {

        private final LayoutInflater inflater = LayoutInflater.from(getContext());

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            if (convertView == null) {
                convertView = inflater.inflate(R.layout.topic_item, parent, false);
            }
            TextView title = (TextView) convertView.findViewById(R.id.title);
            title.setText(getItem(position).title);
            return convertView;
        }
    };
    final ListView topicsView = (ListView) findViewById(R.id.topics);
    topicsView.setAdapter(topicsAdapter);
    topicsView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Topic topic = topicsAdapter.getItem(position);
            Intent intent = new Intent(TitleListActivity.this, ContentActivity.class);
            intent.putExtra("id", topic.id);
            intent.putExtra("title", topic.title);
            intent.putExtra("username", topic.member.username);
            intent.putExtra("url", topic.url);
            intent.putExtra("content", topic.content);
            startActivity(intent);
        }
    });
    //创建volley请求队列
    final RequestQueue queue = Volley.newRequestQueue(this);
    //根据API获取热议主题
    final GsonRequest<TopicList> request = new GsonRequest<TopicList>(Request.Method.GET, "https://www.v2ex.com/api/topics/hot.json", TopicList.class, new Response.Listener<TopicList>() {

        @Override
        public void onResponse(TopicList response) {
            topicsAdapter.clear();
            topicsAdapter.addAll(response);
            topicsAdapter.notifyDataSetChanged();
            swipeRefreshLayout.setRefreshing(false);
        }
    }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError error) {
            Toast.makeText(TitleListActivity.this, "请检查网络", Toast.LENGTH_LONG).show();
        }
    });
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            queue.add(request);
        }
    });
    queue.add(request);
    swipeRefreshLayout.setRefreshing(true);
}
Also used : GsonRequest(com.v2ex.api.GsonRequest) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) ListView(android.widget.ListView) RequestQueue(com.android.volley.RequestQueue) TopicList(com.v2ex.api.TopicList) TextView(android.widget.TextView) Topic(com.v2ex.api.Topic) VolleyError(com.android.volley.VolleyError) ViewGroup(android.view.ViewGroup) Intent(android.content.Intent) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) Response(com.android.volley.Response) LayoutInflater(android.view.LayoutInflater) AdapterView(android.widget.AdapterView) ArrayAdapter(android.widget.ArrayAdapter)

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