小编Jso*_*son的帖子

我可以在不使用ScrollView/ListView的情况下使用Pull to Refresh吗?

我试图在我的应用程序中实现Pull to Refresh.

我用android.support.v4.widget.SwipeRefreshLayout包装我的xml代码并且它正常工作,但GUI看起来不太好.

当我向下拉时,我应该看到带有我定义的颜色的常规动画圆圈图标,对吧?但是我认为它是一个空白圆圈,而不是一个带有颜色的转动.

此外,我不能"玩"它甚至在我拉动它之后保持一段时间,它会下降一秒钟(做它做的事情)然后消失.

我认为这是因为我没有使用ListView而是使用LinearLayout.

你怎么看?

码:

XML:

<android.support.v4.widget.SwipeRefreshLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/swipe">

    <LinearLayout
        android:layout_height="match_parent"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        android:background="#7B68EE"
        android:paddingBottom="@dimen/activity_vertical_margin"
        tools:context=".HomeActivity">

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/loin"
        android:orientation="horizontal">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:text="@string/welcome"
            android:textColor="#B0C4DE"
            android:id="@+id/welcomeBackID"
            android:layout_alignParentTop="true"
            android:layout_alignRight="@+id/webViewCurren"
            android:layout_alignEnd="@+id/webViewCurren" />

        ....

 </android.support.v4.widget.SwipeRefreshLayout>
Run Code Online (Sandbox Code Playgroud)

Java的:

public class HomeActivity extends AppCompatActivity implements SwipeRefreshLayout.OnRefreshListener {

    SwipeRefreshLayout mSwipeRefreshLayout;

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home);

        mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe);
        mSwipeRefreshLayout.setColorSchemeResources(android.R.color.holo_green_light,
                android.R.color.holo_blue_bright,
                android.R.color.holo_orange_light,
                android.R.color.holo_red_light);
        mSwipeRefreshLayout.setOnRefreshListener(this);

    @Override
    public void onRefresh() {
        Toast.makeText(this, "Refresh", Toast.LENGTH_SHORT).show(); …
Run Code Online (Sandbox Code Playgroud)

android listview pull-to-refresh android-studio

8
推荐指数
1
解决办法
1758
查看次数

向 .gitignore 添加新条目不起作用

如果我理解正确,为了“忽略”一个文件,所以当我输入时它不会出现 git status或者git add -A我需要将它添加到 .gitignore 文件中。

我的目标是在向 Git 提交更改时永久忽略某个文件夹和文件。

我尝试在我的编辑器中编辑 .gitignore 文件:

config/
src/package.xml
Run Code Online (Sandbox Code Playgroud)

我保存了文件,提交并推送到 Git,从另一个存储库刷新我的项目,键入 git status并仍然看到 xml 文件和文件夹。

还尝试通过选择“放弃更改”来使用 GItHub 桌面,它会自动将以下几行添加到 .gitignore 中:

*.sublime-workspace
config/.local_store
*.sublime-workspace
src/package.xml
Run Code Online (Sandbox Code Playgroud)

但同样的结果...

项目结构:

          Full
    ________|____________
   |        |            |
config  .gitignore      src
   |                     |
  ...                package.xml
Run Code Online (Sandbox Code Playgroud)

git

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

AttributeError 'NoneType' 对象没有属性 'upload_from_filename'

我在 Linux 上使用 Python 2.7.9,我在 Google-Cloud Server SDK 上遵循 Google 的示例。我的目标是将图像上传到 Google Cloud Platform,但出现以下错误。

File "/home/pi/test.py", line 15, in <module>
  zebraBlob.upload_from_filename(filename='/home/pi/Pictures/testimg.jpg')
AttributeError: 'NoneType' object has no attribute
  'upload_from_filename'
Run Code Online (Sandbox Code Playgroud)

代码:

from firebase import firebase
from google.cloud import storage
import os

firebase = firebase.FirebaseApplication('https://motion-detector-234.firebaseio.com', None)
storage_client = storage.Client.from_service_account_json('Motion Detector-8gf5445fgeeea.json')

bucket = storage_client.get_bucket('motion-detector-210fds717.appspot.com')
print ('bucket', bucket) // output: bucket, motion-detector-210717.appspot.com

zebraBlob = bucket.get_blob('testimg.jpg')
print(zebraBlob) // output: None

zebraBlob.upload_from_filename(filename='/home/pi/Pictures/testimg.jpg')
Run Code Online (Sandbox Code Playgroud)

如何解决?

python firebase google-cloud-platform

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

bucket.get_blob 返回 None

我正在尝试在 Google Cloud Platform 上遵循Google 的这个示例,但它没有按预期工作,当我使用 get_blob 方法时,我得到“ None ”。

(我仔细检查了文件的路径和名称,它是正确的)。

from google.cloud import storage

if __name__ == '__main__':

    storage_client = storage.Client.from_service_account_json('Motion Detector-11eeeea.json')
    bucket = storage_client.get_bucket('motion-detector-11.appspot.com')
    print ('bucket',bucket) //output: bucket, motion-detector-11.appspot.com
    zebraBlob = bucket.get_blob('/home/pi/Pictures/testimg.jpg')
    print (zebraBlob) //output: None
Run Code Online (Sandbox Code Playgroud)

运行 Python 2.7.9。

请告知如何解决此问题。

python google-cloud-platform

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