Bonjour à tous,
Je suis débutant en Android et je veux faire une lisTView personnalisée pour afficher trois champs de textView,
Voila j'ai un peut souci puisse que j'utilise des fragments. et dans le fragment.Activity ou j'ai défini ma listView, j'ai des button, champ de saisir texte juste au haut de ma liste.
Quelqu'un peut-il m'aider ?

Sans beaucoup parler voici mon code:

Voici le Fichier xml.fragment.Activity

Code XML : Sélectionner tout - Visualiser dans une fenêtre à part
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/LinearLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:animateLayoutChanges="false"
    android:orientation="vertical" >
 
    <TextView
        android:id="@+id/title_im_tv"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/instant_message"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textStyle="bold" />
 
    <EditText
        android:id="@+id/im_remotes_edt"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:hint="Remotes" />
 
    <EditText
        android:id="@+id/im_message_edt"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:hint="Message"
        android:inputType="textMultiLine" >
 
        <requestFocus />
    </EditText>
 
    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
 
        <Button
            android:id="@+id/im_send_btn"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@string/send" />
 
        <Button
            android:id="@+id/im_cancel_btn"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@string/cancel" />
 
        <Button
            android:id="@+id/im_other_btn"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Button" />
    </LinearLayout>
 
    <TextView
        android:id="@+id/im_session_state_tv"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:text="Idle" />
 
    <ListView
        android:id="@+id/listMessage"
        android:layout_width="wrap_content"
        android:layout_height="165dp" >
 
    </ListView>
 
</LinearLayout>


Voici Les textView que je veux avoir :

Code XML : Sélectionner tout - Visualiser dans une fenêtre à part
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
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout  xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
 
    <RelativeLayout
     android:layout_width="match_parent"
     android:layout_height="match_parent">
 
         <TextView
              android:id="@+id/message_remote"
              android:layout_width="170dp"
              android:layout_height="350dp"
              android:layout_alignParentRight="true"
              android:layout_centerVertical="true"
              android:text="@string/message_Remote" />
 
         <TextView
              android:id="@+id/im_date_hour"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_above="@+id/message_remote"
              android:layout_alignParentLeft="true"
              android:layout_marginBottom="16dp"
              android:text="@string/date_Hour"
              android:textAppearance="?android:attr/textAppearanceMedium" />
 
          <TextView
              android:id="@+id/im_remote_number"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_alignBaseline="@+id/im_date_hour"
              android:layout_alignBottom="@+id/im_date_hour"
              android:layout_alignParentRight="true"
              android:text="@string/phone_number"
              android:textAppearance="?android:attr/textAppearanceMedium" />
 
          </RelativeLayout>
 
     </LinearLayout>

Voici Mon Adapter personnalisé:

Code Java : Sélectionner tout - Visualiser dans une fenêtre à part
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
public class ImFragmentListViewAdapter extends BaseAdapter {
    private List<ImDisplayedMessage> items;
 
    //Constructor
    public ImFragmentListViewAdapter(Context context, List<ImDisplayedMessage> resultats) {
        this.items = resultats;
        m_context = context;// le context de notre application = getActivity().getApplicationContext();	
    }
 
    @Override
    public int getCount() {
//return the size of list
        return items.size();
    }
 
    @Override
    public Object getItem(int position) {
// to take the element item at the specific position
        return items.get(position);
    }
 
    @Override
    public long getItemId(int position) {
// to know the id of item element at the specific position
        return position;
    }
 
    /**
     * Classe dans laquelle, les élement déclaré seront sur une ligne
     *
     * @author playtv
     */
    private class ViewHolder {
        TextView date;//la date et l'heure
        TextView phoneNumberRemote;
        TextView messageReceive;//si je termine la session j'affiche que la session c'est terminée
    }
 
    //cette fonction permet de liée la liste des string -> ListView
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        LayoutInflater inflater = null;
        if (convertView == null) {
            holder = new ViewHolder();
            holder.messageReceive = (TextView) convertView.findViewById(R.id.message_remote);
            holder.date = (TextView) convertView.findViewById(R.id.im_date_hour);
            holder.phoneNumberRemote = (TextView) convertView.findViewById(R.id.im_remote_number);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.date.setText(items.get(position).getM_sDate());
        holder.phoneNumberRemote.setText(items.get(position).getM_sRemote());
        holder.messageReceive.setText(items.get(position).getM_sMessage());
        return convertView;
    }
}