zoukankan      html  css  js  c++  java
  • eatwhatApp开发实战(七)

      之前我们为app添加了读取本地数据的功能和删除的功能。本次我们来将listview上item项的触控修改为item项上单一控件的触控事件。用item项上的button来实现删除数据。

      先上布局:

    	<TextView 
    	    android:id="@+id/item_text"
    	    android:layout_width="wrap_content"
    	    android:layout_height="wrap_content"
    	    android:textSize="30sp"
    	    android:maxLength="6"
    	    android:layout_centerInParent="true"
    	    android:layout_alignParentLeft="true"
    	    android:text="店名"/>
    	<Button
    	    android:id="@+id/item_btn"
    	    android:layout_width="wrap_content"
    	    android:layout_height="wrap_content"
    	    android:layout_alignParentRight="true"
    	    android:layout_centerInParent="true"
    	    android:text="删除"/>
    

      这其中做了几个修改,item项上店名textview被移至相对父控件左对齐,同时限定了显示上限maxLength="6"。button相对父控件右对齐。显示结果:

      接下来初始化控件button:

    Button btn = (Button) v.findViewById(R.id.item_btn);
    

      注册点击监听,并移植实现删除功能的对应代码即可:

    btn.setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(View arg0) {
        跳出对话框以及删除功能对应的代码
      });
    

      

  • 相关阅读:
    git介绍
    Oracle '26-2月 -19 03.34.47.000000 下午' 字符串日期解析
    ProceedingJoinPoint 某些方法记录一下
    SpringBoot 2.X以上集成redis
    SpringBoot文件上传配置
    editmd输出到前端显示
    Thymeleaf Shiro标签
    Springboot 添加druid监控
    基于SpringBoot的博客项目
    SpringBoot默认首页配置
  • 原文地址:https://www.cnblogs.com/superdo/p/5097283.html
Copyright © 2011-2022 走看看