纯菜鸟一只 求大神给下面两顿代码加上必要的注释……谢谢了
private OnClickListener mGoListener = new OnClickListener() {
public void onClick(View v) {
String s1, s2;
if (v == (View) interSearchButton) {
s1 = start.getText().toString();
s2 = end.getText().toString();
if(s1.trim().length() == 0 ||
s2.trim().length() == 0)
return;
if (!checkTextValid(s1) || !checkTextValid(s2)
|| (s1.indexOf(s2) != -1) || (s2.indexOf(s1) != -1)) {
showDialog1(DIALOG_YES_NO_MESSAGE);
return;
}
processinterSearch(s1, s2);
} else if (v == (View) lineSearchButton) {
s1 = line.getText().toString();
if(s1.trim().length() == 0)
return;
if (!checkTextValid(s1)) {
showDialog1(DIALOG_YES_NO_MESSAGE);
return;
}
processRoadSearch(s1);
} else if (v == (View) stationSearchButton) {
s1 = station.getText().toString();
if(s1.trim().length() == 0)
return;
if (!checkTextValid(s1)) {
showDialog1(DIALOG_YES_NO_MESSAGE);
return;
}
processStationSearch(s1);
} else {
Log.e(Globals.TAG, "error");
}
}
};
void showDialog1(int id) {
CreateDialog(id).show();
}
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tab1" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:padding="10dip">
<TextView android:layout_width="fill_parent" android:id="@+id/tab1_tv1"
android:layout_height="wrap_content" android:text="@string/start"
android:layout_alignParentTop="true" android:paddingBottom="5dip" />
<EditText android:id="@+id/tab1_et1" android:layout_width="fill_parent"
android:singleLine="true" android:layout_height="wrap_content"
android:layout_below="@id/tab1_tv1" />
<TextView android:id="@+id/tab1_tv2" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:padding="5dip"
android:layout_below="@id/tab1_et1" android:text="@string/end" />
<EditText android:id="@+id/tab1_et2" android:layout_below="@id/tab1_tv2"
android:layout_width="fill_parent" android:singleLine="true"
android:layout_height="wrap_content" />
<LinearLayout android:id="@+id/tab1_lay1"
android:layout_width="fill_parent" android:layout_below="@id/tab1_et2"
android:layout_height="10dip"xmlns:android="http://schemas.android.com/apk/res/android" />
<ImageButton android:id="@+id/tab1_b1"
android:layout_below="@id/tab1_lay1" android:layout_width="100dip"
android:layout_height="50dip" android:layout_centerHorizontal="true"
android:src="@android:drawable/ic_menu_search" />
</RelativeLayout>
private OnClickListener mGoListener = new OnClickListener() {
public void onClick(View v) {
String s1, s2;
if (v == (View) interSearchButton) {
s1 = start.getText().toString();
s2 = end.getText().toString();
if(s1.trim().length() == 0 ||
s2.trim().length() == 0)
return;
if (!checkTextValid(s1) || !checkTextValid(s2)
|| (s1.indexOf(s2) != -1) || (s2.indexOf(s1) != -1)) {
showDialog1(DIALOG_YES_NO_MESSAGE);
return;
}
processinterSearch(s1, s2);
} else if (v == (View) lineSearchButton) {
s1 = line.getText().toString();
if(s1.trim().length() == 0)
return;
if (!checkTextValid(s1)) {
showDialog1(DIALOG_YES_NO_MESSAGE);
return;
}
processRoadSearch(s1);
} else if (v == (View) stationSearchButton) {
s1 = station.getText().toString();
if(s1.trim().length() == 0)
return;
if (!checkTextValid(s1)) {
showDialog1(DIALOG_YES_NO_MESSAGE);
return;
}
processStationSearch(s1);
} else {
Log.e(Globals.TAG, "error");
}
}
};
void showDialog1(int id) {
CreateDialog(id).show();
}
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tab1" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:padding="10dip">
<TextView android:layout_width="fill_parent" android:id="@+id/tab1_tv1"
android:layout_height="wrap_content" android:text="@string/start"
android:layout_alignParentTop="true" android:paddingBottom="5dip" />
<EditText android:id="@+id/tab1_et1" android:layout_width="fill_parent"
android:singleLine="true" android:layout_height="wrap_content"
android:layout_below="@id/tab1_tv1" />
<TextView android:id="@+id/tab1_tv2" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:padding="5dip"
android:layout_below="@id/tab1_et1" android:text="@string/end" />
<EditText android:id="@+id/tab1_et2" android:layout_below="@id/tab1_tv2"
android:layout_width="fill_parent" android:singleLine="true"
android:layout_height="wrap_content" />
<LinearLayout android:id="@+id/tab1_lay1"
android:layout_width="fill_parent" android:layout_below="@id/tab1_et2"
android:layout_height="10dip"xmlns:android="http://schemas.android.com/apk/res/android" />
<ImageButton android:id="@+id/tab1_b1"
android:layout_below="@id/tab1_lay1" android:layout_width="100dip"
android:layout_height="50dip" android:layout_centerHorizontal="true"
android:src="@android:drawable/ic_menu_search" />
</RelativeLayout>