作者:小丽丽很可爱 | 来源:互联网 | 2023-05-18 18:00
Verybasicquestion:ImtryingtoenabledisabletheFooterViewofaListViewdynamically.Basicall
Very basic question: I'm trying to enable/disable the FooterView
of a ListView
dynamically. Basically I would like to make it clickable through the setEnable(true/false)
function as soon as the LocationListener
acquires a new location. I was thinking about a public method that get called from within the LocationListener.onLocationChange()
method, with no return but it has to change the FooterView
preference, but I can't figure out how to code it, and if it could work. Any suggestions?
非常基本的问题:我正在尝试动态启用/禁用ListView的FooterView。基本上我想在LocationListener获取新位置后通过setEnable(true / false)函数使其可单击。我正在考虑从LocationListener.onLocationChange()方法中调用的公共方法,没有返回,但它必须更改FooterView首选项,但我无法弄清楚如何编写它,以及它是否可以工作。有什么建议?
In onCreate:
@Override
protected void onCreate(Bundle bundle) {
LayoutInflater inflater = (LayoutInflater)getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
TextView footerView = (TextView)inflater.inflate(R.layout.footer_view, null);
myListView.addFooterView(footerView);
//if (!enabler) footerView.setEnabled(false);
//else footerView.setEnabled(true);
footerView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {}
});
}
The LocationListener methods
LocationListener方法
@Override
public void onLocationChanged(Location currentLocation) {
if (null == mLastLocationReading || mLastLocationReading.getTime() > currentLocation.getTime()){
mLastLocatiOnReading= currentLocation;
enabler=true;
}
if (currentLocation.getTime() > mLastLocationReading.getTime())
mLocationManager.removeUpdates(this);
}
So even if the Listener find a new location it doesn't trigger the if condition enabling the footerView (where I commented out the code). I tried to access footerView.setEnable from a method with no joy. Any help would be very much appreciated.
因此,即使监听器找到一个新位置,它也不会触发启用footerView的if条件(我在其中注释掉了代码)。我试图从没有快乐的方法访问footerView.setEnable。任何帮助将非常感谢。
1 个解决方案