package com.example.five;
import java.util.Random;
import android.content.Context;
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.ImageView;
import com.example.five.R;
public class Tab01 extends Fragment {
Context mContext;
public Tab01(Context context) {
mContext = context;
}
public Tab01() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.activity_tab01, null);
return view;
}
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
int[] images ={R.drawable.a1, R.drawable.a2, R.drawable.a3};
// Get the ImageView
setContentView(R.layout.activity_tab01);
ImageView mImageView = (ImageView)getActivity().findViewById(R.id.myImageView);
// Get a random between 0 and images.length-1
int imageId = (int)(Math.random() * images.length);
// Set the image
mImageView.setBackgroundResource(images[imageId]);
}
}
굵게 칠해놓은 이 쪽이 자꾸 불이 들어오는데요
뭐가 문제인건가요 ?ㅠㅠ 예전에 레이팅바 넣을때는 저렇게 해서 됏는데 지금은 onCreatView 안에 넣어서 view.findViewById 해도 안되네여 ㅠㅠ 도와주소서 ㅠㅠ