subString是String的一个方法,格式为:

public String substring(int beginIndex, int endIndex) 
返回一个新字符串,它是此字符串的一个子字符串。
该子字符串从指定的 beginIndex 处开始,一直到索引 endIndex - 1 处的字符。因此,该子字符串的长度为 endIndex-beginIndex。 
 
示例: 
截取str字符串的第2个和第三个。
String str = "123456789"; str =str.substring(1,3) 
结果:str="23"
 
在Android应用中,删除按键的程序如下:
button_15.setOnClickListener(new View.OnClickListener() {   
 
  @Override
  public void onClick(View v) {
     editText=(EditText)findViewById(R.id.editText);
     textContent=editText .getText().toString();
 
     if(!"" .equals(textContent)){
     //文本框中内容非空时执行删除操作
       text=textContent .substring(0, textContent.length()-1);
       editText.setText(text );
       editText.setSelection(text .length());
 
     }
  }
});
 
 

删除操作——str.subString(0,str.length()-1)的更多相关文章

  1. java 去最后一位字符 str.substring(0,str.length()-1)

    String str = " 中国, 美国 , 意大利 ";String[] arr = str.split(",");for(int i1 =0;i1< ...

  2. str.substring(beginIndex,endIndex)-008

    // 将字符串str前n位放在后面,返回新的字符串 public String headToTail(String str,int n){ if(n==0){ System.out.println(s ...

  3. ajax不跳转页面的快速删除操作,可添加美观样式

    以前我们讲的删除是利用嵌入php代码,跳转到另一个页面,从而降低了删除速度,但我们今天讲的利用ajax不仅可以达到不跳页面快速删除,并且能添加特效来美化页面. 上代码,我们先来做主页面 <!DO ...

  4. JQUERY删除操作

    var path = '<%=request.getContextPath()%>/baseReorganizeController/deleteBaseReorganize';      ...

  5. list删除操作 java.util.ConcurrentModificationException

    首先大家先看一段代码: public static void main(String[] args) { List<String> listStr = new ArrayList<S ...

  6. C++(十)— 字符串进行插入、替换、查找、删除操作、substr

     1.C++中对字符串进行插入.替换.删除操作 #include<iostream> #include<algorithm> #include<stdio.h> # ...

  7. [LeetCode] 583. Delete Operation for Two Strings 两个字符串的删除操作

    Given two words word1 and word2, find the minimum number of steps required to make word1 and word2 t ...

  8. Spring boot+Mybatisplus用AR模式实现逻辑删除操作

    Mybatisplus的AR模式 Active Record(活动记录),是一种领域模型模式,特点是一个模型类对应关系型数据库中的一个表,而模型类的一个实例对应表中的一行记录.ActiveRecord ...

  9. webform 光棒效果,删除操作弹出确定取消窗口

    鼠标移入onmouseover和鼠标移出onmouseout,代码里没大写我这也就不大写了.那首先,我们得获取Class为tr_item里的所有东西,也就是项标签里的数据.然后呢,我们定义一个oldC ...

随机推荐

  1. python 并发编程 进程池与线程池

    一 进程池与线程池 1.为什么需要进程池和线程池 基于多进程或多线程实现并发的套接字通信,然而这种实现方式的致命缺陷是: 服务端的程序运行在一台机器身上,一台机器性能是有极限的,不能无限开线程 服务的 ...

  2. ERROR 1709 (HY000): Index column size too large. The maximum column size is 767 bytes.

    MySQL版本5.6.35 在一个长度为512字符的字段上创建unique key报错 CREATE DATABASE dpcs_metadata DEFAULT CHARACTER SET utf8 ...

  3. leetcode学习目录

    1  leetcode-69. x 的平方根   https://www.cnblogs.com/shoshana-kong/p/9745424.html 2. 3. 4. 5. 6.

  4. eclipse project--->clean作用

    eclipse project-->clean  ,clean主要是class文件删除,并同时编译新的工程,生成新的class文件. 如果修改代码后,在运行时,还是旧代码,可能class文件还是 ...

  5. Python爬虫之简单的爬取百度贴吧数据

    首先要使用的第类库有 urllib下的request  以及urllib下的parse  以及 time包  random包 之后我们定义一个名叫BaiduSpider类用来爬取信息 属性有 url: ...

  6. python里面列表函数的使用及注意

    1.append 在末尾插入一个内容: a= [i for i in range(1,6)] print(a) a.append(100) print(a) 2.insert 指定位置插入内容 ins ...

  7. 重写移动端滚动条[iScroll.js核心代码]

    最近写组件库的时后,发现这个滚动条是真的丑啊,决定重新撸一个滚动条: 首先咱们回顾一下移动端浏览器滚动条特性: 滚动条在开始滚动时渐显,滚动结束后渐隐 滚动条不占内容区宽度,悬浮固定 滚动条高度(深灰 ...

  8. String转int,int转String

    String转int 1) int i = Integer.parseInt([String]);  int i = Integer.parseInt([String],[int radix]); 2 ...

  9. php学习第一天(记录注意事项)

  10. Core Graphics Paths

    Paths中的几个重要元素 Points void CGContextMoveToPoint (    CGContextRef c,    CGFloat x,    CGFloat y ); 指定 ...