Skip to content
Permalink
63525a17dd
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
50 lines (39 sloc) 1.54 KB
package com.example.jianhuayang.myfragments;
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 android.widget.TextView;
import com.example.jianhuayang.myfragments.data.Candidates;
/**
* A simple {@link Fragment} subclass.
*/
public class DetailsFragment extends Fragment {
public static final String POSITION = "position";
public DetailsFragment() {
// Required empty public constructor
}
@Override
public void onStart() {
super.onStart();
Bundle args = getArguments();
if (args != null) {
int position = args.getInt(POSITION);
TextView description = (TextView) getActivity().findViewById(R.id.description);
description.setText(Candidates.candidateDetails[position]);
ImageView imageView = (ImageView) getActivity().findViewById(R.id.imageView);
imageView.setImageResource(Candidates.candidatePhotos[position]);
} else {
TextView description = (TextView) getActivity().findViewById(R.id.description);
description.setText("Click on the names on the left to see details");
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_details, container, false);
}
}