私はaxmlファイルのボタンを持っていて、それはフラグメントから呼び出されました。私はどのようにボタンを使用することができますか?例えば、 "cobaButton"というidのボタンからonclickコマンドを受けたいとします。私はAndroidアプリを開発するためにVisual Studio 2015とXamarinを使用しています。フラグメント上のアクセスボタンビジュアルスタジオxamarin
これはこれは
public class PlanetFragment : DialogFragment
{
public static string ArgPlanetNumber = "planet_number";
ConnectDB db = new ConnectDB();
public override View OnCreateView(LayoutInflater p0, ViewGroup p1, Bundle p2)
{
var i = Arguments.GetInt(ArgPlanetNumber);
if (i == 0)
{
var rootView = p0.Inflate(Resource.Layout.HomePermainan, p1, false);
return rootView;
}
else
{
var rootView = p0.Inflate(Resource.Layout.MyProfile, p1, false);
return rootView;
}
}
}
私のフラグメント・ファイルであり、これは私のAXMLファイルです
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minWidth="25px"
android:minHeight="25px">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout1">
<Button
android:text="Button"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/cobaButton" />
<Button
android:text="Button"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/button2" />
<Button
android:text="Button"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/button3" />
</LinearLayout>
<Button
android:text="Button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/button4" />
を合計し、一般的な方法でそれがフラグメントで動作しませんが、私は何かを逃したのですか? – neneo
は誤った形になっていますが、現在は動作しています。ありがとうございます:D – neneo