(Android)Fragment 的XML不能实现ScrollView上下滑动求解


import java.util.ArrayList;
import java.util.List;

import com.example.beilex.Adapter.Art_adapter;
import com.example.beilex.entity.PublicEntity;
import com.example.beilex_activty.R;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;

public class Dance_Fragment extends Fragment {
private View view;
private GridView gv;
private Art_adapter madapter;

public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// System.out.println("OneFragment  onCreateView");
view = inflater.inflate(R.layout.dance_fragments, container, false);
intview(view);

Exhibition();
gv.setOnItemClickListener(new OnItemClickListener() {

@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int number,
long arg3) {
// TODO Auto-generated method stub
Log.i("点击编号", "编号为:"+number);
}
});
return view;
}

private void intview(View v) {
// TODO Auto-generated method stub
gv = (GridView) v.findViewById(R.id.dance_mygridview_gv);

}
public void Exhibition(){
List<PublicEntity>list= new  ArrayList<PublicEntity>();
PublicEntity pe= new PublicEntity();
pe.setName("小儿舞蹈");
//pe.setBitmap(bitmap);
for(int i=0;i<12;i++){
list.add(pe);
}

madapter=new Art_adapter(getActivity(), list);
gv.setAdapter(madapter);
}
}  
//以上只是例子



<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:text="舞蹈"
                android:textSize="24sp" />

            <com.example.beilex.quote.MyGridView
                android:id="@+id/dance_mygridview_gv"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dip"
                android:gravity="center"
                android:horizontalSpacing="0.0dip"
                android:listSelector="@null"
                android:numColumns="2"
                android:scrollbars="none"
                android:stretchMode="columnWidth"
                android:verticalSpacing="0.0dip" />
        </LinearLayout>
    </ScrollView>

</LinearLayout>

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值