zoukankan      html  css  js  c++  java
  • 1月21日 列表视图listview

    10.ListView

    Java

    package com.example.firstapp.ListView;
    
    import android.os.Bundle;
    import android.view.View;
    import android.widget.AdapterView;
    import android.widget.ListView;
    import android.widget.Toast;
    
    import androidx.annotation.Nullable;
    import androidx.appcompat.app.AppCompatActivity;
    
    import com.example.firstapp.R;
    
    public class ListViewActivity extends AppCompatActivity {
    
        private ListView mLv1;
    
        @Override
        protected void onCreate(@Nullable Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_listview);
            mLv1 = findViewById(R.id.lv_1);
            mLv1.setAdapter(new MyListAdapter(ListViewActivity.this));
            mLv1.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                    Toast.makeText(ListViewActivity.this,"点击"+position,Toast.LENGTH_SHORT).show();
                }
            });
            mLv1.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
                @Override
                public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
                    Toast.makeText(ListViewActivity.this,"长按"+position,Toast.LENGTH_SHORT).show();
                    return true;
                }
            });
        }
    }
    

      

      

  • 相关阅读:
    二分图最大匹配的K&#246;nig定理及其证明
    HDOJ 2389 Rain on your Parade
    HDOJ 1083 Courses
    HDOJ 2063 过山车
    POJ 1469 COURSES
    UESTC 1817 Complete Building the Houses
    POJ 3464 ACM Computer Factory
    POJ 1459 Power Network
    HDOJ 1532 Drainage Ditches
    HDU 1017 A Mathematical Curiosity
  • 原文地址:https://www.cnblogs.com/dty602511/p/14859609.html
Copyright © 2011-2022 走看看