CustomFragmentContent.java
Dosyayı İndir
package com.godoro.androidfragments;
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.TextView;
import java.util.Random;
public class CustomFragmentContent extends Fragment {
public final static String CONTENT_KEY="contentKey";
private Random random=new Random();
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView= inflater.inflate(
R.layout.fragment_custom_fragment_content, container, false);
String contentValue=getArguments().getString(CONTENT_KEY);
TextView contenView=rootView.findViewById(R.id.contenView);
int randomColor=0xFF000000+random.nextInt()%0x00FFFFFF;
contenView.setBackgroundColor(randomColor);
contenView.setText(contentValue);
return rootView;
}
}
Dosyayı İndir