这是包含微调器的片段
ThisEscape
}
这是我想打电话的课程
public class LetsGoFragment extends Fragment implements View.OnClickListener{
//constructor
public static LetsGoFragment newInstance(){
LetsGoFragment fragment = new LetsGoFragment();
return fragment;
}
public LetsGoFragment(){
}
//variable to connect
Spinner spinnerTo;
Spinner spinnerFrom;
Button button;
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
//connecting the fragment to layout
View rootView = inflater.inflate(R.layout.fragment_lets_go, container, false);
//spinner and button
spinnerTo = (Spinner) rootView.findViewById(R.id.spinnerTo);
String textTo = spinnerTo.getSelectedItem().toString();
spinnerFrom = (Spinner) rootView.findViewById(R.id.spinnerFrom);
String textFrom = spinnerTo.getSelectedItem().toString();
button = (Button) rootView.findViewById(R.id.button);
return rootView;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
private void setContentView(int activity_main) {
}
@Override
public void onClick(View v) {
if(spinnerTo.getSelectedItem().equals("Masjid Jamek")&& spinnerFrom.getSelectedItem().equals("Bukit Bintang")){
MasjidJamekToBukitBintang.class.toString();
}
}
}
答案 0 :(得分:0)
您未在onClickListener
button
您需要设置onClickListener
,以便在点击""时使button
行为。
您需要执行以下操作:
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Put here the code you want to run everytime the button is clicked
}
}