마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

프래그먼트에서 액티비티 전환

0 추천

프래그먼트에서 액티비티로 넘어가야하는데 dispalyPicture라는 메소드가 안 먹히네요ㅠㅠ

어떻게 해야할까요?? 

public class Meun_Fragment_Hot extends Fragment {

    public Meun_Fragment_Hot() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.meun_fragment_hot, container, false);
    }


    public void displayPicture(View v) {
        int id = v.getId();
        LinearLayout layout = (LinearLayout) v.findViewById(id);
        String tag = (String) layout.getTag();

        Intent it = new Intent(this, Order.class);
        it.putExtra("it_tag", tag);
        startActivity(it);
    }
}
wh00123 (140 포인트) 님이 2020년 6월 11일 질문

1개의 답변

0 추천
// 다음 코드가 빌드가 될까요?

Intent it = new Intent(this, Order.class);

// 다음 처럼 써야할 것 같은데요.

Intent it = new Intent(getActivity(), Order.class);

 

디자이너정 (42,810 포인트) 님이 2020년 6월 12일 답변
XML에서 onClick="displayPicture를 사용해서 public void displayPicture 메소드를 사용할라고 하는 안 되는 건 어떻게 해결해야 하나요???
...