小编Bha*_*hta的帖子

Android SwipeRefreshLayout与空TextView无法正常工作

我想要做的是,允许用户刷卡并刷新列表,无论数据是否存在都无关紧要.但是当列表视图中存在数据时,列表视图应该是可见的,而当数据不存在时,应该看到空文本视图.在这两种情况下,用户必须能够通过滑动刷新列表.

在这个讨论中尝试了一些解决方案 ,但没有一个听起来有效,采取两个SwipeToRefresh的想法在这里给出的工作正常,但它甚至在从服务器获取数据时显示空容器.

我用自己的逻辑包装Listview和Textview在Relative/FrameLayout中尝试了它,但SwipeToRefresh仅根据其行为接受一个视图

这是我尝试过的xml片段

 <android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/activity_main_swipe_refresh_layout"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.945" >


        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent" >

            <ListView
                android:id="@+id/event_list_eventlist"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:divider="@color/event_background"
                android:dividerHeight="1dp" >
            </ListView>

            <TextView
                android:id="@+id/event_txt_nothing_found"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:layout_centerInParent="true"
                android:layout_centerVertical="true"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textColor="@android:color/darker_gray"
                android:visibility="gone" />
        </RelativeLayout>
    </android.support.v4.widget.SwipeRefreshLayout>
Run Code Online (Sandbox Code Playgroud)

请帮忙

android android-listview swiperefreshlayout

8
推荐指数
2
解决办法
5345
查看次数

如何允许用户在android中仅从内部和外部存储器中选择pdf文件

因为我可以打开下载文件夹,但 PDF 看起来像是禁用的,所以我无法选择 PDF 文件。有没有其他方法可以实现这一目标?

这是按钮单击的代码

case R.id.pdf_Upload:
               Intent intent = new Intent();
            intent.setType("pdf/*");
            intent.setAction(Intent.ACTION_GET_CONTENT);
            startActivityForResult(Intent.createChooser(intent, "Select Pdf"), REQUESTCODE_PICK_Pdf);

            break; 

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        switch (requestCode) {

    case REQUESTCODE_PICK_Pdf:
                if (requestCode == REQUESTCODE_PICK_Pdf && resultCode == RESULT_OK
                        && null != data) {
                    Uri selectedPdf = data.getData();

                    PdfSelected.setVisibility(View.VISIBLE);
                    if (selectedPdf.getLastPathSegment().endsWith("pdf")) {


                        System.out.println("Uri of selected pdf---->" + selectedPdf.toString());
                    } else if (resultCode == RESULT_CANCELED){
                        Toast.makeText(this, "Invalid file type", Toast.LENGTH_SHORT).show();
                    }
                }
    }
Run Code Online (Sandbox Code Playgroud)

权限

 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission …
Run Code Online (Sandbox Code Playgroud)

pdf android android-studio

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

从导航抽屉ActionBar中删除应用程序图标不起作用

我正在开发一个具有设计要求的应用程序,因为它应该只有ActionBar上的Title而不是App Icon.我尝试了从StackOverflow中找到的各种解决方案

getActionBar().setDisplayUseLogoEnabled(false);

    getActionBar().setDisplayShowHomeEnabled(false);

    getActionBar().setIcon(null);
Run Code Online (Sandbox Code Playgroud)

但是到目前为止这些都没有工作,即使我试图通过制作透明的ic_launcher图标并将其放入manifest.xml来进行黑客/修复,但它会导致App安装图标变得透明.请帮忙

getActionBar().setDisplayShowHomeEnabled(false);
Run Code Online (Sandbox Code Playgroud)

在4.4 kitkat中完美运行,但在降级版本中显示了这样的后退箭头在此输入图像描述

我需要像这样在每个设备上工作

在此输入图像描述

android android-actionbar navigation-drawer

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

如何将List <CustomClass>转换为ArrayList <CustomClass>,反之亦然?

我有一个CustomClass,Bean/Model/Pojo它用于从Json保存自定义Obejcts.我希望保存ArrayListCustomClass的内容SharedPreference并在特殊情况下将其恢复.我发现它存储在一个方式SharedPreference 在这里!正确的答案是SpyZip 我能够存储和检索一个,List但我想存储和检索一个ArrayList.

这是一个片段,显示我如何存储和检索值SharedPreference:

    // This method will save custom class ArrayList<Bean>
    public void saveUserFavouriteStations(
            ArrayList<RadioStationBean> radioStation) {
        FavouriteStationHolder = this.getSharedPreferences("stations", 0);
        Editor editor = FavouriteStationHolder.edit();
        Gson gson = new Gson();
        String jsonCars = gson.toJson(radioStation);
        editor.putString("stations", jsonCars);
        System.out.println("Custom ArrayList Saved in App Class");
        editor.commit();
    }

    public ArrayList<RadioStationBean> getUserFavouriteStations() {
        FavouriteStationHolder = this.getSharedPreferences("stations", 0);
        if (FavouriteStationHolder != null) {
            String jsonString = …
Run Code Online (Sandbox Code Playgroud)

java android list arraylist sharedpreferences

-2
推荐指数
1
解决办法
538
查看次数