我正在尝试实施列表。这是 start.xml 文件,它有一个文本框 i ,我正在输入任何单词,并且将打开一个包含该单词的单词列表:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/FrameLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<EditText
android:id="@+id/start_edit"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="top|left"
android:ems="10"
android:hint="Type to search"
android:paddingLeft="50dp" >
<requestFocus />
</EditText>
对于列表视图,我正在使用这个 ListView.xml 文件:
<ImageView
android:id="@+id/image_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="@drawable/abacus_thumbnail"
android:scaleType="centerCrop" />
<ImageView
android:id="@+id/imageView_color_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="@drawable/blue_thumbnail" />
<TextView
android:id="@+id/title_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/image_list"
android:layout_marginLeft="20dp"
android:layout_toRightOf="@+id/image_list"
android:gravity="center"
android:text="Abacus"
android:textColor="#000000"
android:textSize="30sp"
android:textStyle="bold"
android:typeface="sans" />
<TextView
android:id="@+id/textView_meaning_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/title_list"
android:layout_below="@+id/title_list"
android:layout_marginTop="10dp"
android:text="TextView"
android:textColor="#000000"
android:textSize="25sp" />
当我的应用程序启动时,我正在使用 EfficientAdapetr 将一个视图从一个视图转换为另一个视图,EditBox 将为空且背景图像。当输入一个单词时,我在列表项上有 ClickListner,打开一个列表,当单击项目时,这个词将打开。现在的问题是,当我单击列表项时,背景会填充单词但 listView 不会删除。在项目上单击我想用这个词打开我的背景。 这是我的代码:
listAdapter = new EfficientAdapter2(this);
setListAdapter(listAdapter);
private class EfficientAdapter2 extends BaseAdapter implements Filterable,OnItemClickListener {
private Context context;
LayoutInflater inflater;
public EfficientAdapter2(Context context) {
this.context = context;
inflater = LayoutInflater.from(context);
}
public int getCount() {
// if(SearchWordString.isEmpty()==false)
// {
return SearchWordString.size();
/// }
//return 0;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
viewHolder2 holder;
if (convertView == null) {
convertView = inflater.inflate(R.layout.ListView, null);
holder = new viewHolder2();
// Log.i("View","is Null");
convertView.setTag(holder);
} else {
//Log.i("View","is not Null");
holder = (viewHolder2) convertView.getTag();
}
holder.word = (TextView) convertView.findViewById(R.id.title_list);
holder.meaning = (TextView) convertView
.findViewById(R.id.textView_meaning_list);
holder.image = (ImageView) convertView
.findViewById(R.id.image_list);
holder.image_color = (ImageView) convertView
.findViewById(R.id.imageView_color_list);
holder.cell = (RelativeLayout) convertView
.findViewById(R.id.RelativeLayout_list);
try {
“这里的功能”
} catch (IOException e) {
e.printStackTrace();
}
return convertView;
}
这是onItemClick:
protected void onListItemClick(ListView l, View v, int position, long id) {//////// super.onListItemClick(l, v, position, id);
//Log.i("Position",""+position);
changeEverything(position);// here i am converting my ListView to
Start.xml but its on happening
motherOfIndex = position;
}