[英]Android Wear - Add card after onClick
It's the first time I'm working on an android wear application. 这是我第一次使用Android Wear应用程序。 I have implemented a list of items and is all right.
我已经实施了项目清单,可以了。 Now I would like to show to the user an extra information when the users click in one item in a kind of card like in the image.
现在,我想向用户显示一个额外的信息,当用户单击图像中的一种卡片中的一个项目时。
My click
is working ok: 我的
click
正常运行:
@Override
public void onClick(WearableListView.ViewHolder viewHolder) {
//Toast.makeText(this, "working", Toast.LENGTH_SHORT).show();
}
But I have no idea how to popup a card when the user click in an item. 但是我不知道当用户单击项目时如何弹出卡。 Any idea?
任何想法?
Thanks! 谢谢!
EDITED: 编辑:
I have added in my activity_main.xml the code below: 我在我的activity_main.xml中添加了以下代码:
<?xml version="1.0" encoding="utf-8"?>
<android.support.wearable.view.WatchViewStub
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/watch_view_stub"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:rectLayout="@layout/rect_activity_main"
app:roundLayout="@layout/round_activity_main"
tools:context=".MainActivity"
tools:deviceIds="wear">
<android.support.wearable.view.BoxInsetLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="match_parent"
android:layout_width="match_parent">
<FrameLayout
android:id="@+id/frame_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_box="bottom">
</FrameLayout>
</android.support.wearable.view.BoxInsetLayout>
</android.support.wearable.view.WatchViewStub>
Then after fill the list I want to allow to the user to click on any item and show the card, so I have added the code below: 然后,在填写列表后,我要允许用户单击任何项目并显示卡,因此,我在下面添加了代码:
@Override
public void onClick(WearableListView.ViewHolder viewHolder) {
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
CardFragment cardFragment = CardFragment.create("title",
"description");
fragmentTransaction.add(R.id.frame_layout, cardFragment);
fragmentTransaction.commit();
}
and I'm getting an error: 我收到一个错误:
No view found for id 0x7f0e0014 (wk.gon250.myApp/frame_layout) for fragment CardFragment{207c1da5 #0 id=0x7f0e0014}
找不到片段CardFragment {207c1da5#0 id = 0x7f0e0014}的ID 0x7f0e0014(wk.gon250.myApp / frame_layout)的视图
The error make sense but I don't know how to fix the error. 该错误是有道理的,但我不知道如何解决该错误。
The images you have, are showing Cards and there is code snippets here that shows you how to build a card in your app; 您所拥有的图像显示Cards, 此处有代码片段,向您展示如何在应用程序中构建Card。 it is basically a CardFragment and if you are familiar with building a fragment, it shouldn't come as anything strange for you.
它基本上是一个CardFragment ,如果您熟悉构建片段,那么它对您来说应该就不奇怪了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.