您的相册不太可能有uniqueId ' id/no_id/1
'。您可以使用dump.py
. 如果我dump.py --uniqueId
在 4.0.3 Gallery 上运行,我将获得
com.android.internal.policy.impl.PhoneWindow$DecorView NO_ID None id/no_id/1
android.widget.LinearLayout NO_ID None id/no_id/2
android.view.ViewStub id/action_mode_bar_stub None id/action_mode_bar_stub
android.widget.FrameLayout NO_ID None id/no_id/3
android.widget.TextView id/title Gallery id/title
android.widget.FrameLayout id/content None id/content
android.widget.RelativeLayout id/root None id/root
android.widget.GridView id/albums None id/albums
android.widget.LinearLayout NO_ID None id/no_id/4
com.android.camera.GalleryPickerItem id/thumbnail None id/thumbnail
android.widget.TextView id/title All pictures (3) id/title/1
android.widget.LinearLayout NO_ID None id/no_id/5
com.android.camera.GalleryPickerItem id/thumbnail None id/thumbnail/1
android.widget.TextView id/title Download (3) id/title/2
所以,我猜你想要第一张专辑,那么我会使用:
vc = ViewClient(*ViewClient.connectToDeviceOrExit())
firstAlbum = vc.findViewWithTextOrRaise(re.compile('All pictures \(\d+\)'))
firstAlbum.touch()
或(作为oneliner):
ViewClient(*ViewClient.connectToDeviceOrExit()).findViewWithTextOrRaise(re.compile('All pictures \(\d+\)')).touch()
使用正则表达式,您可以选择相册,带有所有图片标题的相册与标题中列出的图片数量无关。