数か月前、私は HTC ONE X を購入しました。インタラクティブなウィジェットとヘルプ機能を使用して、電話で最初の一歩を踏み出す際にユーザーをガイドする方法に感心しました。
私たちが構築しているアプリであるロジャーザットにこのような機能を追加したいのですが、これを実現するのに役立つツール/ライブラリはありますか?
数か月前、私は HTC ONE X を購入しました。インタラクティブなウィジェットとヘルプ機能を使用して、電話で最初の一歩を踏み出す際にユーザーをガイドする方法に感心しました。
私たちが構築しているアプリであるロジャーザットにこのような機能を追加したいのですが、これを実現するのに役立つツール/ライブラリはありますか?
ユーザーが 4 つのメモ ページをナビゲートして指示を確認できるようにするアプリのガイド付きツアーを行いました。コードは次のとおりです。
public static void tour(final Context context, final String title, final int pageNumber,
final Drawable icon, final String[] pageMessage, final int[] layouts, final ViewGroup root) {
Builder tourDialog = new AlertDialog.Builder(context);
int nPage = 0;
if (pageMessage!=null){
tourDialog.setMessage(pageMessage[pageNumber]);
nPage = pageMessage.length;
}
if (layouts!=null){
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
View layout1 = inflater.inflate(layouts[pageNumber], root);
tourDialog.setView(layout1);
//tourDialog.setView(views[pageNumber]);
nPage = layouts.length;
}
tourDialog.setTitle(title+" (page "+(pageNumber+1)+"/"+nPage+")");
tourDialog.setPositiveButton("Prev",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int whichButton) {
tour(context, title, pageNumber-1, icon, pageMessage,layouts, root);
return;
}
});
tourDialog.setNeutralButton("Next",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int whichButton) {
tour(context, title, pageNumber+1, icon, pageMessage,layouts, root);
return;
}
});
tourDialog.setNegativeButton("Ok",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int whichButton) {
return;
}
});
if (icon!=null)
tourDialog.setIcon(icon);
AlertDialog dialog = tourDialog.create();
dialog.show();
if (pageNumber==0)
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
else if (pageNumber==nPage-1){
dialog.getButton(AlertDialog.BUTTON_NEUTRAL).setEnabled(false);
}
}
使用例:
int[] layout = {R.layout.note1, R.layout.note2, R.layout.note3, R.layout.note4}; //resource id of each page's layout
tour(context, "Notes ", 0,getResources().getDrawable(R.drawable.gmpte_logo_25px),null, layout, (ViewGroup) findViewById(R.id.root));
ノート ページのレイアウトの例:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/root"
android:padding="10dip">
<TextView android:id="@+id/text_before"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFF"
android:textSize="16dp"
android:text="@string/note1_before_text"
android:layout_marginTop="10dp"/>
<ImageView android:id="@+id/image"
android:contentDescription="@string/desc"
android:src="@drawable/mylocation_blue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/text_before"
/>
<TextView
android:id="@+id/text_after"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/text_before"
android:layout_below="@+id/image"
android:text="@string/note1_after_text"
android:textColor="#FFF"
android:textSize="16dp" />
</RelativeLayout>
ノート ページごとに独自のレイアウトを記述する必要がありますがandroid:id="@+id/root"
、各ページのルート レイアウトには同じ ID ( ) を使用します。
アプリ ツアーを作成するための単純なコンポーネントを含む小さなライブラリを作成しました。それは私のケースに非常に限定されていますが、あなたのケースかもしれません. Single LessonCardView 初めてアクティビティを開始したとき、またはボタンをクリックしたときに表示されました。ありがとう https://github.com/dnocode/DnoLib
ViewPager とフラグメントを使用して、ヘルプ画面を表示します。それに関する多くの情報が見つかります。