我有一個問題,滾動在GridView
我的要求是自動檢索來自服務器的數據的GridViewGridView控件不滾動
每一件事情是確定的,但是這個GridView控件不向下滾動
這是我的Java程序,這個XML代碼後會
這是我的適配器
gridAllPackages.setOnScrollListener(new OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {//blank}
@Override
public void onScroll(AbsListView view, int firstVisibleItem,int visibleItemCount, int
totalItemCount) {
if (loadingMore) {
if (totalItemCount > mPreviousTotal) {
mPreviousTotal = totalItemCount;
pageNo++;
if (pageNo > 3) {
loadingMore = false;
}
int lastInScreen = firstVisibleItem + visibleItemCount;
if((lastInScreen == totalItemCount)&&(loadingMore)&& lastInScreen != 0){
if (pDialog != null && pDialog.isShowing())
pDialog.dismiss();
}}}
}});}
末適配器
這是我網格視圖
private GridView gridAllPackages;
gridAllPackages.setOnScrollListener(new OnScrollListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View view, int pos, long arg3) {
try {
TextView tv = (TextView) view.findViewById(R.id.tv_gradename);
select_catagory_list.setText(tv.getTag().toString());
lvTag = arg0.getTag().toString();
String tags[] = tv.getTag().toString().split("<<>>");
position_catagory = pos;
if (lvTag.equalsIgnoreCase("Select catagory")) {
if (select_catagory_list.getText().toString().equalsIgnoreCase("Select catagory"))
select_catagory_list.setTag("null");
else select_catagory_list.setTag(tags[0]);
listviewPopupWindowProvider.selectedItem(tags[1]);
}
listviewPopupWindowProvider.dismissPopup();
select_catagory_list.setText(tv.getText().toString());
} catch (Exception e) {
e.printStackTrace();
}
}
這裏是我的XML代碼
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<GridView
android:id="@+id/all_relavant_package_grid"
android:layout_width="match_parent"
android:layout_height="1151dp"
android:layout_marginTop="10dp"
android:numColumns="3"
android:scrollbars="vertical"
android:smoothScrollbar="true" >
</GridView>
</LinearLayout>
可能是您的適配器有問題。你的網格視圖適配器在哪裏? – koherent
嘗試刪除這個'android:scrollbars =「vertical」'gridview只有垂直滾動 –
改變android:layout_height =「1151dp」android:layout_height =「match_parent」 – Dharmik