我正在尝试用字母字母创建一个快速滚动。有人可以告诉我如何在另一个班级中使用the code in this question?我有一个类,有一个方法返回我需要放在快速滚动中的字母,所以我想在另一个中使用这个类,如下所示:
MyListAdaptor mla = new MyListAdaptor(getApplicationContext(), itemsBP);
mla.xyz();
然后我不知道如何让这些字母出现。
如果可以,请帮助我。
答案 0 :(得分:0)
在一些研究结束时,我意识到缺少的是以下代码,必须放在OnCreate()中:
LinkedList <String> mLinked <String> = new LinkedList ();
for (int i = 0; i <nomes.length: i + +) {
mLinked.add (names [i]);
}
setListAdapter (new MyListAdaptor (this, mLinked));
ListView lv = getListView ();
lv.setFastScrollEnabled (true);
lv.setOnItemClickListener (new OnItemClickListener () {
public void onItemClick (AdapterView <?> parent, View view,
int position, long id) {
/ / When clicked, show a toast with the TextView text
Toast.makeText (getApplicationContext (), ((TextView) view). GetText (). ToString (), Toast.LENGTH_SHORT.) Show ();
}
});
将类代码放在类MyListAdaptor Main OnCreate()。
中感谢您的帮助,希望将来可以帮助其他人。