-
Notifications
You must be signed in to change notification settings - Fork 0
/
FragmentMethod.java
58 lines (52 loc) · 1.92 KB
/
FragmentMethod.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package com.example.dell.aryashitlist;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
/**
* Created by kriti on 05-01-2017.
*/
public class FragmentMethod extends Fragment {
TextView fragmentTextView;
ImageView fragmentImageView;
RelativeLayout fragmentRelativeLayout;
String name;
String status;
String description;
int img_location;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_layout,container,false);
Bundle bundle = getArguments();
name = bundle.getString("name");
status = bundle.getString("status");
description = bundle.getString("description");
img_location = bundle.getInt("img_location");
getIDs(view);
setEvents();
return view;
}
private void setEvents() {
fragmentTextView.setText(description);
fragmentImageView.setImageResource(img_location);
if(status.equals("dead")){
fragmentRelativeLayout.setBackgroundColor(Color.RED);
}
else if(status.equals("alive")){
fragmentRelativeLayout.setBackgroundColor(Color.GREEN);
}
}
private void getIDs(View view){
fragmentTextView = (TextView)view.findViewById(R.id.fragmentTextView);
fragmentImageView = (ImageView)view.findViewById(R.id.fragmentImageView);
fragmentRelativeLayout = (RelativeLayout)view.findViewById(R.id.fragmentRlativeLayout);
}
}