我正在尝试创建一个字母顺序的快速卷轴。谁能告诉我如何在另一个类中使用the code in this question?我有一个类,它的方法返回需要放在快速滚动中的字母,所以我想在另一个类中使用这个类,如下所示:
MyListAdaptor mla = new MyListAdaptor(getApplicationContext(), itemsBP);
mla.xyz();但是我不知道怎样才能让这些字母出现。
如果可以的话,请帮帮我。
发布于 2012-09-21 17:45:27
在一些研究的最后,我意识到缺少的是下面的代码,它必须放在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 ()中。
感谢你的帮助,希望这能在未来帮助其他人。
https://stackoverflow.com/questions/12473778
复制相似问题