我有一个parse.com应用程序,当我点击列表项时,我想要它,它会将文本输出,当我再次单击它时,它会将文本恢复正常。有关如何做到这一点的任何想法?谢谢!
public class AgendaActivity extends Activity {
//First Call ArrayList
private ArrayList<String> assignments;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
assignments = new ArrayList<String>();
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, assignments);
setListAdapter(adapter);
agendaList();
}
//Query List
public void agendaList(){
ParseQuery<ParseObject> query = ParseQuery.getQuery("Agenda");
query.whereEqualTo("userId", ParseUser.getCurrentUser());
query.findInBackground(new FindCallback<ParseObject>() {
//Show up in list
@Override
public void done(List<ParseObject> parseObjects, ParseException e) {
if (e == null) {
// If there are results, update the list of posts
// and notify the adapter
assignments.clear();
//Gets all data from parse
for (ParseObject post : parseObjects) {
assignments.add(post.getString("name") + "\n" + "Date Due: " +
post.getString("dueDate") + "\n" + "Class: " + post.getString("class"));
}
((ArrayAdapter<String>)getListAdapter()).notifyDataSetChanged();
} else {
//Error Logging
Log.d("Post retrieval", "Error: " + e.getMessage());
}
}
});
}
答案 0 :(得分:0)
使用它!
tv是textView。
tv.setPaintFlags(tv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); //this strikes through the text
另外,对于非打击使用此,
tv.setPaintFlags( tv.getPaintFlags() & (~ Paint.STRIKE_THRU_TEXT_FLAG));
在适配器类的getView方法中使用它。
另外,建议您可以浏览ParseQueryAdapter列出从Parse获取的对象。