Android的长期点击选项卡 [英] Android long click on tab
本文介绍了Android的长期点击选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一些选项卡的TabHost和标签上做了长期preSS后,我想要得到的位置或选项卡这是长pressed标签,而不是当前选项卡的被显示。
下面有我在其中创建长preSS监听器TabHost一些code:
I have a TabHost with some tabs, and after doing a long press on a tab, I want to get the position or the tag of the tab which was long pressed, and not the current tab that is showed. Below there is some code in which I create the long press listener for the TabHost:
myTabHost.getTabWidget().getChildAt(i).setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
// TODO Auto-generated method stub
return false;
}
});
任何解决方案?正确的TabHost在我的情况申请听众?
Any solution? Is correct to apply the listener at TabHost in my case?
推荐答案
我解决我的问题,增加了标签的标签信息的视图,然后我连着在视图中的侦听器,并打印这个标签:
I resolved my problem adding to the view of the tab a tag information , and then I attached at the view a listener that gets and prints this tag:
View tabView= mTabHost.getTabWidget().getChildAt(i);
// set the tag information at the view of the tab (the tag contains the position number of the tab)
tabView.setTag( Integer.valueOf(i));
tabView.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
// TODO Auto-generated method stub
// I print the number position of the tab
Log.d("tab number", ((Integer)view.getTag()).toString() );
return false;
}
});
这篇关于Android的长期点击选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文