我正在开发一款Android应用。我正在使用listview和SwipefreshLayout。但是当我使用SwipefreshLayout刷新列表视图时,加载圈永远不会被隐藏。我在片段中使用它。
这是布局文件
import Tkinter
WindowBox = Tkinter.Tk()
WindowBox.geometry("250x200")
WindowBox.title("Welcome to E-UPSR")
getusername1 = Tkinter.StringVar()
getpassword1 = Tkinter.StringVar()
getusername2 = Tkinter.StringVar()
getpassword2 = Tkinter.StringVar()
LabelName = Tkinter.Label (WindowBox, text="Username:")
LabelName.pack()
TxtBoxName = Tkinter.Entry (WindowBox, textvariable= getusername1)
TxtBoxName.pack()
LabelName = Tkinter.Label (WindowBox, text="Password:")
LabelName.pack()
TxtBoxName = Tkinter.Entry (WindowBox, textvariable= getpassword1)
TxtBoxName.pack()
student=[]
def read():
getusername1 = Tkinter.StringVar()
getpassword1 = Tkinter.StringVar()
if len(getusername1.get() and getpassword1())== 0:
labelShowName=Tkinter.Label(WindowBox, text="Invalid").pack()
else:
addstudent = open ("student.txt", "w")
addstudent.read("Username:" + getusername1.get())
addstudent.read("Password: " + getpassword1.get())
addstudent.close ()
WindowBox.withdraw()
MenuBox.deiconify()
return
def register():
WindowBox.withdraw()
RegBox.deiconify()
return
RegBox = Tkinter.Tk()
RegBox.geometry("250x200")
RegBox.title("register")
LabelName = Tkinter.Label (RegBox, text="Username:")
LabelName.pack()
TxtBoxName = Tkinter.Entry (RegBox, textvariable= getusername2)
TxtBoxName.pack()
LabelName = Tkinter.Label (RegBox, text="Password:")
LabelName.pack()
TxtBoxName = Tkinter.Entry (RegBox, textvariable= getpassword2)
TxtBoxName.pack()
RegBox.withdraw()
def back():
RegBox.withdraw()
WindowBox.deiconify()
return
def save():
while True:
getusername2 = Tkinter.StringVar()
getpassword2 = Tkinter.StringVar()
if len(getusername2.get() and getpassword2())== 0:
labelShowName=Tkinter.Label(RegBox, text="Please key-in").pack()
else:
addstudent = open ("student.txt", "w")
addstudent.write('Username:' + getusername2.get())
addstudent.write('Password:' + getpassword2.get())
labelShowName=Tkinter.Label(RegBox, text="Done").pack()
len(getusername2.get() and getpassword2.get())!= 0
return
MenuBox = Tkinter.Tk()
MenuBox.geometry("250x200")
MenuBox.title("MainMenu")
MenuBox.withdraw()
BtnName = Tkinter.Button (RegBox, text="Back", command=back).pack()
BtnName = Tkinter.Button (RegBox, text="Enter", command=save).pack()
BtnName = Tkinter.Button (WindowBox, text="Register", command=register).pack()
BtnName = Tkinter.Button (WindowBox, text="Proceed", command=read).pack()
WindowBox.mainloop()
这就是我在片段
中使用它的方式<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- place your view here -->
<ListView
android:dividerHeight="@dimen/list_item_divider_height"
android:padding="@dimen/list_padding"
android:divider="@color/whitesmoke"
android:id="@+id/listview_podcast_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"></ListView>
</android.support.v4.widget.SwipeRefreshLayout>
<TextView
android:layout_below="@+id/swipe_refresh_layout"
android:textSize="17dp"
android:textStyle="bold"
android:textColor="@color/black"
android:textAlignment="center"
android:id="@+id/tf_no_records"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
加载圈永远不会被隐藏回来,如下面的屏幕截图
我的代码有什么问题,如何解决?
答案 0 :(得分:4)
刷新后您必须set refreshing
到false
refresher.setRefreshing(false);
<强>更新强>
科特林:
refresher.isRefreshing = false