I am a novice at writing a new word - this simple little Android application, just make out a layout very simple ListView, containing words and interpretation, and now want to achieve after clicking TextView will include examples of the hidden changes to show.
class listListener implements OnItemClickListener {
public void onItemClick (AdapterView arg0, View arg1, int arg2, long arg3)
{
/ / TODO Auto-generated method stub
}
}
But I do not know in this function should sentence TextView visibility ==
Simply tears ah ~ ~ ~ ~ Help
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Visibility "Change" TextView's
Reply:
Where cattle where cattle ah ~ ~ ~ ~
Reply:
Their top up ~
Reply:
arg1 This parameter is the ListView row that you select View, you can view this in the various controls hidden.
For example, to find one of the TextView words, (TextView) view.findViewById (R.id.xxx);
ps: you post this time, a large cattle or sleeping, lol's lol, even to the Forum, see this knot quote rate, also passing it.
Reply:
Depends on what you use adapter, adapter if they are defined in the definition of adapter written inside
Reply:
Reply:
Thank you moderator! ! !
Reply:
Wrote a demo, test the next, can you try it. only one item layout textview, do not pass up.
public class MainActivity extends Activity {
private static final String TAG = "MainActivity";
private ListView listView = null;
private MyAdapter adapter = null;
@ Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setContentView (R.layout.activity_main);
listView = (ListView) findViewById (R.id.listView);
adapter = new MyAdapter ();
adapter.setData (getData ());
listView.setAdapter (adapter);
}
public List
List
for (int i = 0; i <50; i + +) {
list.add (i + "");
}
return list;
}
private class MyAdapter extends BaseAdapter {
private List
@ Override
public int getCount () {
/ / TODO Auto-generated method stub
return list.size ();
}
public void setData (List
this.list = list;
}
@ Override
public Object getItem (int position) {
/ / TODO Auto-generated method stub
return list.get (position);
}
@ Override
public long getItemId (int position) {
/ / TODO Auto-generated method stub
return position;
}
@ Override
public View getView (int position, View convertView, ViewGroup parent) {
ViewHolder viewHoler = null;
if (viewHoler == null) {
convertView = View.inflate (getApplicationContext (),
R.layout.item, null);
viewHoler = new ViewHolder ();
viewHoler.tv = (TextView) convertView
. FindViewById (R.id.textview);
convertView.setTag (viewHoler);
} Else {
viewHoler = (ViewHolder) convertView.getTag ();
}
viewHoler.tv.setText (list.get (position));
convertView.setOnClickListener (new MyOnClickListener (viewHoler,
position));
return convertView;
}
class ViewHolder {
private TextView tv;
}
class MyOnClickListener implements OnClickListener {
ViewHolder vh;
int position;
public MyOnClickListener (ViewHolder vh, int position) {
this.vh = vh;
this.position = position;
}
@ Override
public void onClick (View v) {
list.remove (position);
list.add (position, "");
/ / Notification adapter
modified listadapter.notifyDataSetChanged ();
}
}
}
}
Reply:
onClick method, the use of this more simple list.set (position, "");
Another fact here is the operation of the database, you can under appropriate modifications.
Reply:
Blessings, has been resolved, thank you
No comments:
Post a Comment