请帮我!我想做一个公交车时刻表应用程序,但我不能用两个按钮来做这个活动。它说“_tiz_oda 类型的重复方法 addListenerOnButton()”。活动布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="._tiz_oda" >
<TextView
android:id="@+id/textView_10_oda"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="@string/text_10_1"
android:textSize="18sp" />
<TextView
android:id="@+id/textView_10_10_oda"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="@string/button_10"
android:textSize="18sp" />
<TextView
android:id="@+id/textView_10_ora_oda"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/button_10_oda"
android:text="@string/text_ora" />
<TextView
android:id="@+id/textView_10_ures_oda"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView_10_munkanap_oda"
android:layout_below="@+id/textView_10_munkanap_oda"
android:layout_marginTop="24dp"
android:text="@string/text_ures" />
<TextView
android:id="@+id/textView_10_szabad_oda"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/button_10_oda"
android:layout_toRightOf="@+id/textView_10_munkanap_oda"
android:text="@string/text_szabad" />
<GridView
android:id="@+id/gridView_10_oda"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/textView_10_szabad_oda"
android:layout_centerHorizontal="true"
android:numColumns="3" />
<Button
android:id="@+id/button_10_megallok_oda"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignTop="@+id/button_10_oda"
android:text="@string/text_megallok" />
<Button
android:id="@+id/button_10_oda"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@+id/textView_10_irany_oda"
android:text="@string/text_10_3" />
<TextView
android:id="@+id/textView_10_irany_oda"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/button_10_oda"
android:layout_below="@+id/textView_10_oda"
android:layout_marginLeft="33dp"
android:text="@string/text_irany" />
<TextView
android:id="@+id/textView_10_munkanap_oda"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView_10_ora_oda"
android:layout_alignBottom="@+id/textView_10_ora_oda"
android:layout_alignLeft="@+id/textView_10_oda"
android:layout_marginLeft="20dp"
android:text="@string/text_munkanap" />
</RelativeLayout>
和活动.java:
package com.szfvar.buszmenetrend;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.GridView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
public class _tiz_oda extends Activity {
Button button;
GridView gridView_10;
static final String[] numbers = new String[] {
"4", "35,50", "35",
"5", "00,20,50", "20",
"6", "25,50", "25",
"7", "20", "20",
"8", "20", "20",
"9", "20", "20",
"10", "20", "20",
"11", "20", "20",
"12", "20,45", "20",
"13", "20,50", "20",
"14", "20,50", "25",
"15", "20,50", "20",
"16", "20,50", "20",
"17", "20,50", "20",
"18", "20", "20",
"19", "00,25", "25",
"20", "25", "25",
"21", "20", "20",
"22", "35", "35",};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tiz_oda);
gridView_10 = (GridView) findViewById(R.id.gridView_10_oda);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, numbers);
gridView_10.setAdapter(adapter);
gridView_10.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
Toast.makeText(getApplicationContext(),
((TextView) v).getText(), Toast.LENGTH_SHORT).show();
}
});
addListenerOnButton();
}
public void addListenerOnButton() {
final Context context = this;
button = (Button) findViewById(R.id.button_10_oda);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = new Intent(context, _tiz_vissza.class);
startActivity(intent);
}
});
addListenerOnButton();
}
public void addListenerOnButton() {
final Context context = this;
button = (Button) findViewById(R.id.button_10_megallok_oda);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = new Intent(context, _tiz_megallok_oda.class);
startActivity(intent);
}
});
}
}
请帮忙!提前致谢!