ListFragment Shadow und Arrow

  • Antworten:4
B S.
  • Forum-Beiträge: 16

11.04.2013, 11:02:32 via Website




Ich habe eine ein ListFragment und daneben ein FrameLayout. Nun möchte ich so wie bei GMail einen Schatten und ein Pfeil einfügen, habe bis keine Lösung gefunden auch bei Google habe ich nix vernünftiges gefunden.

Hat das einer von euch das schonmal gemacht? vielleicht Beispiel Code??

Vielen Dank für eure Hilfe

Antworten
Mac Systems
  • Forum-Beiträge: 1.727

11.04.2013, 11:45:39 via Website

Code ? Selectoren machen das denke ich mal.

Windmate HD, See you @ IO 14 , Worked on Wundercar, Glass V3, LG G Watch, Moto 360, Android TV

Antworten
B S.
  • Forum-Beiträge: 16

11.04.2013, 13:43:20 via Website

Mac Systems
Code ? Selectoren machen das denke ich mal.

main_layout
1<LinearLayout xmlns:android=".."
2 xmlns:tools="http://schemas.android.com/tools"
3 android:id="@+id/LinearLayout1"
4 android:layout_width="match_parent"
5 android:layout_height="match_parent"
6 tools:context=".MainActivity" >
7
8 <fragment
9 android:id="@+id/fragmentList"
10 android:name="android.support.v4.app.ListFragment"
11 android:layout_width="0dp"
12 android:layout_height="match_parent"
13 android:layout_weight="1">
14 </fragment>
15 <LinearLayout
16 android:id="@+id/fragment_place"
17 android:layout_width="0dp"
18 android:layout_height="match_parent"
19 android:layout_weight="3"
20 android:orientation="vertical"
21 android:background="#FFFFFF"
22 >
23 </LinearLayout>
24</LinearLayout>

1public class MainActivity extends FragmentActivity {
2
3 @Override
4 protected void onCreate(Bundle savedInstanceState) {
5 super.onCreate(savedInstanceState);
6 setContentView(R.layout.activity_main);
7
8 //ArrayAdapter adapter = ArrayAdapter.createFromResource(this, R.array.Liste, android.R.layout.simple_list_item_1);
9 ListButton list = new ListButton(this);
10 FragmentManager fm = getSupportFragmentManager();
11 ListFragment fmList = (ListFragment)fm.findFragmentById(R.id.fragmentList);
12 fmList.setListAdapter(list);
13
14 Fragment01 f1 = new Fragment01();
15 FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
16 transaction.add(R.id.fragment_place, f1);
17 transaction.commit();
18 fmList.getListView().setOnItemClickListener(new OnItemClickListener() {
19 @Override
20 public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3) {
21 onSelectFragment(arg2);
22 }
23 });
24 }
25
26 public void onSelectFragment(int arg2) {
27
28 Fragment newFragment;
29
30 if (arg2 == 0) {
31 newFragment = new Fragment01();
32 } else if (arg2 == 1) {
33 newFragment = new Fragment02();
34 } else {
35 newFragment = new Fragment01();
36 }
37
38 FragmentTransaction transaction = getSupportFragmentManager()
39 .beginTransaction();
40 transaction.replace(R.id.fragment_place, newFragment);
41 transaction.addToBackStack(null);
42 transaction.commit();
43 }
44
45 public class ListButton extends BaseAdapter
46 {
47 private Context fContext;
48 private List<ButtonObj> listButton;
49 public ListButton(Context fContext) {
50 super();
51 this.fContext = fContext;
52 listButton = new ArrayList<ButtonObj>();
53 try {
54 FillListButtonList();
55 } catch (ClassNotFoundException e) {
56 e.printStackTrace();
57 }
58 }
59
60
61
62 @Override
63 public int getCount() {
64 return listButton.size();
65 }
66
67 @Override
68 public Object getItem(int position) {
69 return null;
70 }
71
72 @Override
73 public long getItemId(int position) {
74 return 0;
75 }
76
77 @Override
78 public View getView(int position, View convertView, ViewGroup parent) {
79 View lView = convertView;
80
81 LayoutInflater lLayoutInflater = (LayoutInflater) fContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
82 lView = lLayoutInflater.inflate(R.layout.act_button, null);
83
84
85 ImageView lImageView = (ImageView) lView.findViewById(R.id.act_button_imageView);
86 TextView lTextView = (TextView) lView.findViewById(R.id.act_button_textView);
87
88
89 try
90 {
91 final ButtonObj buttonObj = listButton.get(position);
92 lTextView.setText(buttonObj.getTitle());
93 lImageView.setImageDrawable(fContext.getResources().getDrawable(buttonObj.getDrawable()));
94
95
96 lView.setOnClickListener(new OnClickListener()
97 {
98 public void onClick(View v)
99 {
100 if(buttonObj.getCallClass() != null)
101 {
102 Fragment newFragment = null;
103
104 try {
105 newFragment = (Fragment) buttonObj.getCallClass().newInstance();
106 } catch (InstantiationException e) {
107 e.printStackTrace();
108 } catch (IllegalAccessException e) {
109 e.printStackTrace();
110 }
111
112
113 FragmentTransaction transaction = getSupportFragmentManager()
114 .beginTransaction();
115 transaction.replace(R.id.fragment_place, newFragment);
116 transaction.addToBackStack(null);
117 transaction.commit();
118 }
119 else {
120
121 }
122
123 }
124 });
125 }
126 catch (Exception e)
127 {
128 e.printStackTrace();
129 }
130
131 return lView;
132 }
133
134 }

Das ist nur ein erster Entwurf habe auch schon einige andere Ansätze versucht. Kann auch gerne unabhängig von diesem Code sein.

— geändert am 11.04.2013, 13:43:48

Antworten
Mac Systems
  • Forum-Beiträge: 1.727

11.04.2013, 14:19:26 via Website

Schön das du hier die Arbeit andere machen lassen willst. Ich würde mir das mal anlesen, dazu gibt es je reichlich bsp. im Netz. Lies dir das lieber mal an, da ansich nichts codiert werden muss

Windmate HD, See you @ IO 14 , Worked on Wundercar, Glass V3, LG G Watch, Moto 360, Android TV

Antworten
B S.
  • Forum-Beiträge: 16

11.04.2013, 15:21:51 via Website

Mac Systems

Ich würde mir das mal anlesen, dazu gibt es je reichlich bsp. im Netz. Lies dir das lieber mal an, da ansich nichts codiert werden muss
B S.

habe bis jetzt keine Lösung gefunden auch bei Google habe ich nix vernünftiges gefunden.
Mac Systems
Schön das du hier die Arbeit andere machen lassen willst.
Wofür gibt es ein Forum wenn man nicht nach Lösungsansetzen fragen darf?
Steht Irgendwo das du mir das Programmieren sollst?? Habe ich nicht geschrieben das ich es versucht habe und keine vernünftige Lösung gefunden habe!!

Wenn jemand eine Idee hat oder es schonmal gemacht hat bitte melden.

Vielen Dank

Antworten