Skip to main content
Publicación cerrada como "Duplicada" por lois6b, ComunidadBot

public class MainMenu extends Fragment implements OnClickListener{

public class MainMenu extends Fragment implements OnClickListener{

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        View v = inflater.inflate(R.layout.fragment_main_menu, container, false);

        Button b = (Button) v.findViewById(R.id.btnme1);
        b.setOnClickListener(this);
        return v;
    }

    @Override
    public void onClick(View vi) {
        int id = vi.getId();
        switch (id) {
            case R.id.btnme1:
                TextView ncant1 = (TextView) vi.findViewById(R.id.txtcant1);
                ncant1.setText("85");
                break;
        }
    }
}

}

Deseo colocar el numero 85 en un textview [R.id.txtcant1] al presionar el boton

public class MainMenu extends Fragment implements OnClickListener{

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {

    View v = inflater.inflate(R.layout.fragment_main_menu, container, false);

    Button b = (Button) v.findViewById(R.id.btnme1);
    b.setOnClickListener(this);
    return v;
}

@Override
public void onClick(View vi) {
    int id = vi.getId();
    switch (id) {
        case R.id.btnme1:
            TextView ncant1 = (TextView) vi.findViewById(R.id.txtcant1);
            ncant1.setText("85");
            break;
    }
}

}

Deseo colocar el numero 85 en un textview [R.id.txtcant1] al presionar el boton

public class MainMenu extends Fragment implements OnClickListener{

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        View v = inflater.inflate(R.layout.fragment_main_menu, container, false);

        Button b = (Button) v.findViewById(R.id.btnme1);
        b.setOnClickListener(this);
        return v;
    }

    @Override
    public void onClick(View vi) {
        int id = vi.getId();
        switch (id) {
            case R.id.btnme1:
                TextView ncant1 = (TextView) vi.findViewById(R.id.txtcant1);
                ncant1.setText("85");
                break;
        }
    }
}

Deseo colocar el numero 85 en un textview [R.id.txtcant1] al presionar el boton

Origen Enlace

OnClick en Fragment

public class MainMenu extends Fragment implements OnClickListener{

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {

    View v = inflater.inflate(R.layout.fragment_main_menu, container, false);

    Button b = (Button) v.findViewById(R.id.btnme1);
    b.setOnClickListener(this);
    return v;
}

@Override
public void onClick(View vi) {
    int id = vi.getId();
    switch (id) {
        case R.id.btnme1:
            TextView ncant1 = (TextView) vi.findViewById(R.id.txtcant1);
            ncant1.setText("85");
            break;
    }
}

}

Deseo colocar el numero 85 en un textview [R.id.txtcant1] al presionar el boton