java - 将gridview与其他项目一起使用时滚动整个屏幕
问题描述
我有一个显示一些项目“图像和按钮”的片段我想滚动所有屏幕,而不仅仅是网格视图,我进行了一些搜索并使用了一些代码,但它卖不出去,所以我该怎么做...... ………………………………………………………………………………………………………………………………………… ………………………………………………………………………………………………………………………………………… ..................................................... .....................
这是问题4 秒
我的代码
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:overScrollMode="never"
android:scrollbars="none"
tools:context=".Fragment.ImagesFragmentProject.HomeImagesFragment">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF">
<!-- editor's chooses text -->
<TextView
android:id="@+id/choose_text2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/scrollView_image"
android:paddingTop="20dp"
android:paddingRight="10dp"
android:paddingBottom="6dp"
android:text="إختيار المحررين"
android:textColor="@color/colorBlack"
android:textSize="18sp"
android:textStyle="bold" />
<GridView
android:id="@+id/gridview_image_choose"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_below="@id/choose_text2"
android:background="#fff"
android:columnWidth="100dp"
android:fastScrollEnabled="false"
android:gravity="center"
android:horizontalSpacing="0dp"
android:numColumns="auto_fit"
android:paddingTop="8dp"
android:scrollbars="none"
android:stretchMode="columnWidth"
android:verticalSpacing="0dp" />
</RelativeLayout>
Java 类
public class HomeImagesFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
/* ArrayList for chooseImages */
final String[] chooseImages = {
"https://i1.wp.com/www.newphotodownload.info/wp-content/uploads/2018/12/%D8%A8%D9%88%D8%B3%D8%AA%D8%A7%D8%AA-%D8%AF%D9%8A%D9%86%D9%8A%D8%A9-61-1.jpg",
"https://quotess.cc/wp-content/uploads/2020/01/4688.jpg",
"https://whatt.cc/wp-content/uploads/2018/07/4443.jpg",
"https://i1.wp.com/www.newphotodownload.info/wp-content/uploads/2018/12/%D8%A8%D9%88%D8%B3%D8%AA%D8%A7%D8%AA-%D8%AF%D9%8A%D9%86%D9%8A%D8%A9-61-1.jpg",
"https://quotess.cc/wp-content/uploads/2020/01/4688.jpg",
"https://whatt.cc/wp-content/uploads/2018/07/4443.jpg",
"https://i1.wp.com/www.newphotodownload.info/wp-content/uploads/2018/12/%D8%A8%D9%88%D8%B3%D8%AA%D8%A7%D8%AA-%D8%AF%D9%8A%D9%86%D9%8A%D8%A9-61-1.jpg"
};
/* make new object and find the view "GridView" */
GridView gridview1 = rootView.findViewById(R.id.gridview_image_choose);
// display all the images from Array on it
gridview1.setAdapter(new PicassoImagesAdapter(getActivity(), chooseImages));
/* display the image when click on it */
// we made a class for this method called "PicassoDisplayImageAdapter"
gridview1.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// get the image
String image = chooseImages[position];
Intent intent = new Intent(getActivity(), PicassoDisplayImageAdapter.class);
intent.putExtra("imageUrl", image);
getActivity().startActivity(intent);
}
});
return rootView;
}
}
解决方案
推荐阅读
- python - DNNClassifier:“DataFrame”对象没有属性“dtype”
- python - 列表中元组的交集 - python
- hyperledger-fabric - Hyperledger Fabric CA:http:来自 127.0.0.1:53356 的 TLS 握手错误:tls:收到长度为 21536 的超大记录
- vue.js - Vue flickr 应用程序中的搜索栏未提供预期结果
- javascript - 将任何 URL 转换为相对 URL
- meteor - 当我尝试运行 npm install 时 Meteor 抛出 gyp 错误
- c# - 使用 IdentityServer4 加载项目时 DefaultUserSession 中的 NullReferenceException
- powershell - 获取一个AD用户的经理并将其输入到表格的列中
- css - 使用 ::before 作为创造空间的方式的目的是什么?
- swift - Swift 不会在具有关联类型的协议扩展函数中调用重写的类 var