小编shr*_*yas的帖子

查看寻呼机和片段生命周期

我有一个ViewPager,一次加载三个页面.如果我从第1页到第2页再扫描到第3页,则第一页(片段)转到 onPause().然后,如果我滑动到第二页,onResume()即使页面1仍然对用户不可见,第一页也会出现.所以,我的问题是:如何区分代码中的第一页和第二页?例如,如果我必须在片段可见时运行一段代码,那么它是如何完成的?

android android-lifecycle android-fragments android-viewpager

37
推荐指数
3
解决办法
3万
查看次数

Viewpager不在协调器布局中滚动

这是我的布局

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="280dp"
        android:fitsSystemWindows="true"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapse_toolbar"
            android:layout_width="match_parent"
            android:layout_height="250dp"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="100dp"
                android:gravity="top"
                android:minHeight="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                app:titleMarginTop="15dp">

            </android.support.v7.widget.Toolbar>

            <android.support.design.widget.TabLayout
                android:id="@+id/category_tabs"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:layout_gravity="bottom"
                android:background="#f0f0f0"
                android:focusable="false" />

            <View
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:background="@color/talview_color_1" />

        </android.support.design.widget.CollapsingToolbarLayout>

    </android.support.design.widget.AppBarLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />  

</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)

我正在尝试在滚动时将tablayout固定在顶部.它不起作用.更重要的是,每个viewpager片段中都有一个listview,listview滚动在listview中不起作用.

任何人都可以帮忙

android listview android-viewpager android-coordinatorlayout android-collapsingtoolbarlayout

5
推荐指数
1
解决办法
3359
查看次数

是否有可能将stickylistviewheader与crisbanes pulltorefresh合并?

我构建了一个应用程序,其中pulltorefresh和stickylistHeaders都需要.我已经在应用程序中实现了pulltorefresh但是无法使其与stickyListHeaders一起使用.是否有可能合并这两个库?或者有其他选择吗?任何想法?

user-interface android pull-to-refresh

4
推荐指数
1
解决办法
1426
查看次数

okhttp多部分图像上传文件名

我试图从Android手机上传图像到服务器.这就是我到目前为止所做的

  OkHttpClient client = new OkHttpClient();
            MultipartBuilder builder = new MultipartBuilder();


builder.type(MultipartBuilder.FORM).addPart(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), requestPackage.getJsonParam().toString()));
            for (int i = 0; i < requestPackage.getPics().size(); i++) {
                builder.addPart(RequestBody.create(MediaType.parse("image/png"/* + i*/), new File(URI.create(requestPackage.getPics().get(i)))));
            Log.i("image to upload",URI.create(requestPackage.getPics().get(i)).toString());
            }
            requestBody = builder.build();
     Request request = new Request.Builder().url(requestPackage.getUri()).post(requestBody).build();
            try {
                response = client.newCall(request).execute();
                if (!response.isSuccessful()) throw new IOException("Unexpected code " + response);
    //            System.out.println(response.body().string());
                return response.body().string();
            } catch (IOException e) {
                e.printStackTrace();
            }
Run Code Online (Sandbox Code Playgroud)

我如何为不同的部分添加名称.因为如果没有名称(关键),那么服务器端的人将如何存储它?

mobile android http okhttp

4
推荐指数
2
解决办法
1万
查看次数