报了空指针,不知道为什么

报了空指针,不知道为什么

爱你是孤单的心事 发布于 2021-11-29 字数 2722 浏览 959 回复 1

private void initDeviceTimeListView() {

lvDeviceTimeAdapter = new ListViewNewsAdapter(this, lvTimeDeviceData,

R.layout.news_listitem);


lvTime_footer = getLayoutInflater().inflate(R.layout.listview_footer,


null);

lvTime_foot_more = (TextView) lvTime_footer

.findViewById(R.id.listview_foot_more);

lvTime_foot_progress = (ProgressBar) lvTime_footer

.findViewById(R.id.listview_foot_progress);

lvTime = (PullToRefreshListView) findViewById(R.id.frame_listview_Time);

lvTime.setAdapter(lvDeviceTimeAdapter);

lvTime.setOnItemClickListener(new OnItemClickListener() {

@Override

public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,

long arg3) {

// TODO Auto-generated method stub

TextView t = (TextView) lvTime.getChildAt(arg2).findViewById(

R.id.news_listitem_tongdao);

UIHelper.showTimeRedirect(Main.this, t.getText().toString());

}

});

lvTime.setOnScrollListener(new AbsListView.OnScrollListener() {

public void onScrollStateChanged(AbsListView
view, int scrollState) {

lvTime.onScrollStateChanged(view, scrollState);

// 数据为空--不用继续下面代码了

if (lvTimeDeviceData.isEmpty())

return;

// 判断是否滚动到底部

boolean scrollEnd = false;

try {

if (view.getPositionForView(lvTime_footer) == view.getLastVisiblePosition())

scrollEnd = false;

} catch (Exception e) {

Log.e("onscrollListener", e.toString());

scrollEnd = false;

}

int lvDataState = StringUtils.toInt(lvTime.getTag());

if (scrollEnd && lvDataState == UIHelper.LISTVIEW_DATA_MORE) {

lvTime.setTag(UIHelper.LISTVIEW_DATA_LOADING);

lvTime_foot_more.setText(R.string.load_ing);

lvTime_foot_progress.setVisibility(View.VISIBLE);

// 当前pageIndex

int pageIndex = lvTimeSumData / AppContext.PAGE_SIZE;

loadTimeDeviceData(pageIndex,lvTimdeHandler,UIHelper.LISTVIEW_ACTION_SCROLL);

}

}

public void onScroll(AbsListView view, int firstVisibleItem,

int visibleItemCount, int totalItemCount) {

lvTime.onScroll(view, firstVisibleItem, visibleItemCount,

totalItemCount);

}

});

lvTime.setOnRefreshListener(new PullToRefreshListView.OnRefreshListener() {

public void onRefresh() {

loadTimeDeviceData( 0, lvTimdeHandler,UIHelper.LISTVIEW_ACTION_REFRESH);

}

});

lvTime.setVisibility(View.GONE);

}

view.getPositionForView(lvTime_footer)报空指针

如果你对这篇文章有疑问,欢迎到本站 社区 发帖提问或使用手Q扫描下方二维码加群参与讨论,获取更多帮助。

扫码加入群聊

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

屌丝范 2021-11-30 1 楼

lvVideo.addFooterView(lvVideo_footer);// 添加底部视图 必须在setAdapter前

还是自己发现了