zoukankan      html  css  js  c++  java
  • 级控件下(三)

    级控件下(三)

     

    上下文菜单
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.menu);
    TextView tv=(TextView) findViewById(R.id.tv00);
    //tv注册上下文菜单
    registerForContextMenu(tv);
    }
    @Override
    public void onCreateContextMenu(ContextMenu menu, View v,
    ContextMenuInfo menuInfo) {
    menu.add("保存");
    menu.add("删除");
    menu.add("退出");
    super.onCreateContextMenu(menu, v, menuInfo);
    }
    使用资源文件实现上下文菜单
    <item
    android:id="@+id/save"
    android:title="保存"
    ></item>
    <item
    android:id="@+id/delete"
    android:title="删除"
    ></item>
    <item
    android:id="@+id/help"
    android:title="帮助"
    />
    MenuInflater flaInflater=getMenuInflater();
    flaInflater.inflate(R.menu.options2, menu);
    menu.setHeaderIcon(R.drawable.icon);
    menu.setHeaderTitle("帮助");

    4.Gallery控件
    Gallery gallery;
    int [] imgs={R.drawable.sss,R.drawable.icon,R.drawable.sss,R.drawable.icon11};
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.gallery1);
    gallery=(Gallery) findViewById(R.id.gly);
    List<Map<String, Integer>> data=new ArrayList<Map<String,Integer>>();
    for(int i=0;i<imgs.length;i++){
    int img=imgs[i];
    Map<String, Integer> map=new HashMap<String, Integer>();
    map.put("img", img);
    data.add(map);
    }
    SimpleAdapter simpleAdapter=new 
    SimpleAdapter(this, data, R.layout.gallery2,
    new String[]{"img"},
    new int []{R.id.ivgr});
    gallery.setAdapter(simpleAdapter);
    }
    gallery.setOnItemClickListener(new OnItemClickListener() {

    @Override
    public void onItemClick(AdapterView<?> arg0, View arg1, int pos,
    long arg3) {
    iv.setImageResource(imgs[pos]);
    }
    });

  • 相关阅读:
    阿米巴
    linux系统和依赖包常用下载地址
    chm格式文件能打开,但看不到内容问题
    云计算的三层SPI模型
    云计算相关的一些概念Baas、Saas、Iaas、Paas
    IOS 开发环境,证书和授权文件等详解
    Android MDM参考
    理解RESTful架构
    联想小新Air2020锐龙版在Ubuntu下添加指纹识别
    避免踩坑,这才是为知笔记导入印象笔记数据的正确姿势
  • 原文地址:https://www.cnblogs.com/hangekgmx/p/6924186.html
Copyright © 2011-2022 走看看