私LinearLayout
は3つの画像を含むを持っています:
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="0dp"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
tools:context=".MainActivity"
android:orientation="horizontal"
android:layout_gravity="center" >
<ImageView
android:id="@+id/imgFB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/fb"
android:padding="5dp" />
<ImageView
android:id="@+id/imgTW"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/tw"
android:padding="5dp" />
<ImageView
android:id="@+id/imgLIN"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/lin"
android:padding="5dp" />
</LinearLayout>
アクティビティ内で ( dialog
is being called before)として呼び出します。
ImageView iv1 = (ImageView) dialog.findViewById(R.id.imgFB);
ImageView iv2 = (ImageView) dialog.findViewById(R.id.imgTW);
ImageView iv3 = (ImageView) dialog.findViewById(R.id.imgLIN);
メソッドを使用しonClick()
て、アプリが存在する場合はアプリを開くか、URL が添付された Web ブラウザーを開くにはどうすればよいですか?
//Example
public void onClick(View v) {
if (iv1 is clicked()) {
Check if FB is installed, if it is take them to my FB page
If FB is not installed, open the browser and take them to my FB page
}
}