RequestingActivityの更新
1 parent 357f718 commit e5cb6afe5617b2fc74e0ea1d26dd821726208f85
k-fujii authored on 6 Jul 2023
Showing 3 changed files
View
13
app/src/main/AndroidManifest.xml
<activity
android:name=".RequestingActivity"
android:exported="true"
android:label="@string/title_activity_requesting">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
 
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MyPageActivity"
android:exported="true"
<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/title_activity_maps">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.MAIN" />-->
 
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
<!-- </intent-filter>-->
</activity>
 
<activity
android:name=".TestActivity"
View
33
app/src/main/java/com/example/nemophila/RequestingActivity.java
package com.example.nemophila;
 
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.DialogFragment;
 
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_requesting);
 
//右上のボタンで投稿画面(PostActivity)へ遷移
//フレンド検索ボタン
Button toPostButton = (Button)findViewById(R.id.requestingSearchButton);
toPostButton.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
}
});
}
 
//フレンド送信のダイアログを表示
public void showDialog(View view) {
DialogFragment dialogFragment = new RequestingFragment();
dialogFragment.show(getSupportFragmentManager(), "requesting_dialog");
}
 
//フレンド申請のためのダイアログフラグメント
public class RequestingFragment extends DialogFragment {
 
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
 
builder.setTitle("フレンド申請")
.setMessage("(申請先のユーザー名)")
.setPositiveButton("フレンド申請", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// このボタンを押した時の処理を書きます。
}
})
.setNegativeButton("キャンセル", null);
return builder.create();
}
}
}
View
1
■■■■
app/src/main/res/layout/activity_requesting.xml
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="#00BCD4"
android:text="検索"
android:onClick="showRequestingDialog"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.454"
app:layout_constraintStart_toEndOf="@+id/inputRequestingId"