Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.test;
- import android.app.Activity;
- 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;
- public class content_fragment extends Fragment {
- public static final int[] TextQuellen = new int[] { R.string.item1,
- R.string.item2, R.string.item3 };
- private int textIndex = -1;
- public void onAttach(Activity activity) {
- super.onAttach(activity);
- Bundle extras = getActivity().getIntent().getExtras();
- if (extras != null) {
- textIndex = extras.getInt("selectedIndex");
- }
- }
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.content_fragment, container,
- false);
- if (textIndex >= 0) {
- TextView text = (TextView) view.findViewById(R.id.text_content);
- text.setText(TextQuellen[textIndex]);
- }
- return view;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement