-
Notifications
You must be signed in to change notification settings - Fork 0
/
AddActivity.java
74 lines (60 loc) · 2.43 KB
/
AddActivity.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package jp.co.futureantiques.gorillamemo;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import jp.co.futureantiques.gorillamemo.DataBase.DBManager;
public class AddActivity extends AbstractMemoBaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
Log.i("LogMoveOnAddActivity", "追加画面へ遷移しました");
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add);
//EditViewとの紐付け
mHead = findViewById(R.id.para_title);
mBody = findViewById(R.id.para_body);
//登録処理
Button registerButton = findViewById(R.id.register);
registerButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.i("LogPushButton", "登録処理ボタンが押されました");
DBManager dataBaseManager = new DBManager(AddActivity.this);
//EditTextに入力された値を変数へ格納する
head = mHead.getText().toString();
body = mBody.getText().toString();
//DataBaseManagerクラスのinsertメソッドを使用してDBへ保存
dataBaseManager.insert(head, body);
//AddActivityを閉じる
finish();
}
});
//MainActivityへ遷移
Button sendButton = findViewById(R.id.menu_button);
sendButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
case R.id.home_icon_button:
Log.i("home_icon_buttonP", "ホームiconが選択されました。");
Intent intent0 = new Intent(AddActivity.this, MainActivity.class);
startActivity(intent0);
return true;
case R.id.add_icon_button:
Intent intent = new Intent(AddActivity.this, AddActivity.class);
startActivity(intent);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}