void nextFindStr(String str,int cur,int end){
if(cur>end){
this.statubar.setText("没有找到!");
}
else{
int i=this.text.getText().indexOf(str);
if(i>=0){
this.text.setSelectionStart(i);
this.text.setSelectionEnd(i+str.length());
this.statubar.setText("已经在:"+i+" 位置找到!");
}
else{
nextFindStr(str,++cur,end);
} }
}
void upFindStr(String str,int cur){
if(cur<0){
this.statubar.setText("没有找到!");
}else{
int i=this.text.getText().lastIndexOf(str);
if(i>=0){
this.text.setSelectionStart(i);
this.text.setSelectionEnd(i+str.length());
this.statubar.setText("已经在:"+i+" 位置找到!");
}else{
upFindStr(str,--cur);
}
}
}
void replaceStr(String findStr,String replaceStr,int cur,int end){
if(cur>end){
this.statubar.setText("没有找到!");
}else{
int i=this.text.getText().indexOf(findStr);
if(i>0){
this.text.setSelectionStart(i);
this.text.setSelectionEnd(i+findStr.length());
this.text.replaceRange(replaceStr,this.text.getSelectionStart(),this.text.getSelectionEnd());
}else{
replaceStr(findStr,replaceStr,++cur,end);
}
} }
if(cur>end){
this.statubar.setText("没有找到!");
}
else{
int i=this.text.getText().indexOf(str);
if(i>=0){
this.text.setSelectionStart(i);
this.text.setSelectionEnd(i+str.length());
this.statubar.setText("已经在:"+i+" 位置找到!");
}
else{
nextFindStr(str,++cur,end);
} }
}
void upFindStr(String str,int cur){
if(cur<0){
this.statubar.setText("没有找到!");
}else{
int i=this.text.getText().lastIndexOf(str);
if(i>=0){
this.text.setSelectionStart(i);
this.text.setSelectionEnd(i+str.length());
this.statubar.setText("已经在:"+i+" 位置找到!");
}else{
upFindStr(str,--cur);
}
}
}
void replaceStr(String findStr,String replaceStr,int cur,int end){
if(cur>end){
this.statubar.setText("没有找到!");
}else{
int i=this.text.getText().indexOf(findStr);
if(i>0){
this.text.setSelectionStart(i);
this.text.setSelectionEnd(i+findStr.length());
this.text.replaceRange(replaceStr,this.text.getSelectionStart(),this.text.getSelectionEnd());
}else{
replaceStr(findStr,replaceStr,++cur,end);
}
} }
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货