【发布时间】:2015-07-09 13:41:28
【问题描述】:
我正在尝试从字符串中获取第一个和最后一个字符(数字),但我不知道该怎么做。
public void getadrrss (){
SharedPreferences sharedPreferences = getPreferences(Context.MODE_PRIVATE);
String Key = getString(R.string.address);
String existingAddress = sharedPreferences.getString(Key, null);
if (existingAddress ==null) {
existingAddress=("11");
}
if (existingAddress !=null){
EditText txt1 = (EditText)findViewById(R.id.editText1);
EditText txt2 = (EditText)findViewById(R.id.editText2);
EditText txt11 = (EditText)findViewById(R.id.editText11);
txt11.setText((existingAddress), TextView.BufferType.EDITABLE);
//**The problem is here**
//GET first and last character (number) FROM existingAddress
txt1.setText(Left(existingAddress, 1), TextView.BufferType.EDITABLE);
txt2.setText(Right(existingAddress,1), TextView.BufferType.EDITABLE);
}
}
【问题讨论】:
-
是否需要获取字符串的第一个和最后一个字符(必须是数字)?
-
到目前为止你尝试了什么?您的问题包含很多挫败感,但甚至没有一次尝试。 Android SDK中没有
Left和Right方法,是你自己写的吗?你为什么不给我们看这些sn-ps? -
我用左右函数来说明我想要什么...谢谢回复
标签: android get numbers character entity-framework-migrations