Answer the question
In order to leave comments, you need to log in
The button on the fragment does not work, how to fix it?
There is a fragment called ChildFragment1.java. It has a button whose task is to open a new activity.
package com.example.smartnovotroitsk.Navigation.ChildFragment;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import com.example.smartnovotroitsk.Navigation.ChildActivity;
import com.example.smartnovotroitsk.R;
import com.example.smartnovotroitsk.Web.Web_Med;
/**
* A simple {@link Fragment} subclass.
*/
public class ChildFragment1 extends Fragment {
Button btntomed;
public ChildFragment1() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, final ViewGroup container,
Bundle savedInstanceState) {
View inflatedView = inflater.inflate(R.layout.fragment_child_fragment1, container, false);
btntomed = (Button) inflatedView.findViewById(R.id.btntomed);
btntomed.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btntomed:
Intent intent = new Intent(getActivity(), Web_Med.class);
startActivity(intent);
break;
default:
break;
}
}
}
}
error: reached end of file while parsing
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question