내 문제는 내 listView 내 레이아웃의 모든 항목을 반복한다는 것입니다. 이 listView의 맨 아래에 편집 텍스트와 버튼이 있어야합니다. 하지만 여기에서는 listView의 각 행에 대해 텍스트와 버튼 편집이 반복되며 이유를 알지 못합니다. 누군가가 나를 도울 수 있다면 활동 :Android : 버튼 및 텍스트 편집 listView에서 반복
public class MessActivity extends ListActivity
{
public Channel chan;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setListAdapter(Network.getInstance().Messages);
Bundle b = getIntent().getExtras();
this.chan = (Channel) b.get("chanSelected");
//add all message of selected chan to the messAdapter
for (int i = 0 ; i < this.chan.getListMessage().size() ; i++) {
Message mess = this.chan.getListMessage().get(i);
Network.getInstance().addMessage(mess);
}
setContentView(R.layout.mess_list);
}
}
어댑터를 :
public class MessageAdapter extends ArrayAdapter<Message>
{
private Context context;
private int textViewResourceId;
public MessageAdapter(Context context, int textViewResourceId)
{
super(context, textViewResourceId);
this.context = context;
this.textViewResourceId = textViewResourceId;
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
View row = convertView;
MessHolder holder = null;
//row null
if(row == null)
{
LayoutInflater inflater = ((Activity)context).getLayoutInflater();
row = inflater.inflate(textViewResourceId, parent, false);
holder = new MessHolder();
holder.texte = (TextView)row.findViewById(R.id.listMess);
row.setTag(holder);
}
else
{
holder = (MessHolder)row.getTag();
}
Message mess = getItem(position);
holder.texte.setText(mess.getText());
return row;
}
static class MessHolder
{
TextView texte;
}
}
레이아웃 :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@android:id/list">
</ListView>
<TextView
android:id="@+id/listMess"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:padding="10dp"
android:textSize="16sp" >
</TextView>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="bottom" >
//edittext
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="text" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="Envoyer" />
</LinearLayout>
</LinearLayout>
당신의 도움에 감사드립니다.
좋아, 내가 시도 할 것이다. 하지만 addFooterView 대신 머리글이 있다고 생각하십니까? – user1364017
죄송합니다. – skywall
도와 주셔서 감사합니다. 시도했지만 바닥 글이 목록보기에 나타나지 않습니다. – user1364017