下面是我的代码,我只想在文本上显示特定值,当单击显示完整值时,这个引用不能帮助我 android 如何从给定字符串中减去字符串
Button e01;
String value;
String[] days = new String[7];
for (int i = 0; i < 7; i++) {
Log.d("TAG",df.format(calendarGlobal.getTime()));
days[i] = df.format(calendarGlobal.getTime());
//i want to display only 11
days[1]= // 2013/09/11
String[] stringArray = days[1].split("/");
String elevenString = stringArray[stringArray.length-1];
e01.setText(elevenString);
e01.setTag(days[1]);
//e01.setText(elevenString); show error if i replace /e01.setText(elevenString);
/// with e01.setTag(days[1]); is show same value on text and on click on toast i
// want to show only"11" on e01.setText("11");
// when click on e01 show full value on Toast // 2013/09/11
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.e01:
value = e01.getTag().toString();
Toast.makeText(this, value, Toast.LENGTH_SHORT) .show();
public void calculateWeek(int currentweekno) {
// TODO Auto-generated method stub
// days.clear();
// Set the calendar to monday of the current week
// calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
calendarGlobal = Calendar.getInstance();
DateFormat df = new SimpleDateFormat("yyyy/MM/dd");
calendarGlobal.add(Calendar.WEEK_OF_YEAR, +currentweekno);
calendarGlobal.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
String[] days = new String[7];
for (int i = 0; i < 7; i++) {
// days.add(df.format(calendarGlobal.getTime()));
Log.d("TAG",df.format(calendarGlobal.getTime()));
days[i] = df.format(calendarGlobal.getTime());
e01.setText("11");
e01.setTag(days[1]);