계정 추가 액티비티 모두 추가

수정 화면 추가
This commit is contained in:
DESKTOP-1A3P75F\lee
2022-08-18 01:13:36 +09:00
parent a31e1aa04a
commit cb421d3a36
10 changed files with 359 additions and 365 deletions

View File

@@ -31,6 +31,9 @@
android:supportsRtl="true"
android:theme="@style/Theme.QTagger"
tools:targetApi="31">
<activity
android:name=".Activity.AccountModify"
android:exported="false" />
<activity
android:name=".test"
android:exported="false" />

View File

@@ -34,8 +34,8 @@ public class AccountAdd extends AppCompatActivity {
@Override
public void onClick(View v) {
String acId = editAccountId.getText().toString();
String acName = editAccountId.getText().toString();
String acDapt = editAccountId.getText().toString();
String acName = editAccountName.getText().toString();
String acDapt = editAccountDapt.getText().toString();
if(acId.isEmpty() || acName.isEmpty() || acDapt.isEmpty())
{

View File

@@ -1,12 +1,22 @@
package com.qtagger.Activity;
import androidx.annotation.DrawableRes;
import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.utils.widget.ImageFilterButton;
import androidx.room.Room;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
import com.qtagger.Database.Account;
import com.qtagger.Database.AppDatabase;
@@ -15,30 +25,126 @@ import com.qtagger.R;
import java.util.List;
public class AccountList extends AppCompatActivity {
ScrollView scrollView;
TableLayout tableLayout;
ScrollView scrollView;
LinearLayout linearLayout;
AppDatabase db;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_account_list);
scrollView = (ScrollView)findViewById(R.id.scrollview_AccountList);
tableLayout = (TableLayout)findViewById(R.id.table_Account);
linearLayout = (LinearLayout)findViewById(R.id.linearList);
db = Room.databaseBuilder(this,AppDatabase.class,"AccountDB").allowMainThreadQueries().build();
//tableLayout.addView();
findViewById(R.id.imageFilterButton_Back).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
TableRow tableRow = new TableRow(this);
tableRow.setLayoutParams(new TableLayout.LayoutParams());
}
AppDatabase db = Room.databaseBuilder(this,AppDatabase.class,"AccountDB").allowMainThreadQueries().build();
@Override
protected void onStart() {
super.onStart();
linearLayout.removeAllViewsInLayout();
//초기 데이터 세팅
List<Account> accountList = db.accountDao().getAll();
for (Account ac: accountList) {
//계정 개수만큼 추가
addAccountView(ac);
}
}
private void addAccountView(Account account)
{
TableLayout tableLayout = new TableLayout(this);
TableLayout.LayoutParams params = new TableLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,inttodp(150));
params.setMargins(inttodp(40),inttodp(20),inttodp(40),0);
tableLayout.setLayoutParams(params);
tableLayout.setBackgroundResource(R.drawable.tablelayout_background);
TableRow tableRow = new TableRow(this);
tableRow.setLayoutParams(new TableRow.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT));
TextView textId = createTxt(account.getAccountId());
ImageFilterButton btnModi = createBtn(R.drawable.edit_modify_icon_icons_com);
ImageFilterButton btnRemove = createBtn(R.drawable.trash_bin_icon_icons_com_67981);
tableRow.addView(textId);
tableRow.addView(btnModi);
tableRow.addView(btnRemove);
TableRow tableRow2 = new TableRow(this);
TextView textName = createTxt(account.getAccountName());
tableRow2.addView(textName);
TableRow tableRow3 = new TableRow(this);
TextView textDapt = createTxt(account.getAccountDapt());
tableRow3.addView(textDapt);
tableLayout.addView(tableRow);
tableLayout.addView(tableRow2);
tableLayout.addView(tableRow3);
linearLayout.addView(tableLayout);
btnModi.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//수정 화면
Intent intent = new Intent(getApplicationContext(), AccountModify.class);
intent.putExtra("Id",account.getId());
startActivity(intent);
}
});
btnRemove.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
db.accountDao().delete(account);
linearLayout.removeView(tableLayout);
}
});
}
private TextView createTxt(String txt)
{
TextView textView = new TextView(this);
TableRow.LayoutParams textLayout = new TableRow.LayoutParams(inttodp(160),inttodp(40));
textLayout.setMargins(inttodp(10),0,0,0);
textView.setLayoutParams(textLayout);
textView.setText(txt);
textView.setTextColor(Color.BLACK);
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP,24);
return textView;
}
private ImageFilterButton createBtn(@DrawableRes int id)
{
ImageFilterButton button = new ImageFilterButton(this);
button.setBackgroundResource(id);
TableRow.LayoutParams btnLayout = new TableRow.LayoutParams(inttodp(32),inttodp(32));
btnLayout.setMargins(inttodp(10),0,0,0);
button.setLayoutParams(btnLayout);
return button;
}
private int inttodp(int dp)
{
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,dp,getResources().getDisplayMetrics());
}
}

View File

@@ -0,0 +1,96 @@
package com.qtagger.Activity;
import androidx.appcompat.app.AppCompatActivity;
import androidx.room.Room;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.qtagger.Database.Account;
import com.qtagger.Database.AppDatabase;
import com.qtagger.R;
import org.w3c.dom.Text;
import java.util.List;
public class AccountModify extends AppCompatActivity {
TextView textAccountId;
EditText editAccountName, editAccountDapt;
Button btnModify;
Account findAccount = null;
AppDatabase db;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_account_modify);
textAccountId = (TextView)findViewById(R.id.textView_AccountId);
editAccountName = (EditText)findViewById(R.id.textView_AccountName);
editAccountDapt = (EditText)findViewById(R.id.textView_AccountDapt);
btnModify = (Button) findViewById(R.id.button_save);
findViewById(R.id.imageFilterButton_Back).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
Intent intent = getIntent();
int id = intent.getIntExtra("Id",-1);
if(id != -1)
{
db = Room.databaseBuilder(this, AppDatabase.class, "AccountDB").allowMainThreadQueries().build();
List<Account> accountList = db.accountDao().getAll();
for (Account ac: accountList) {
if(ac.getId() == id)
{
findAccount = ac;
break;
}
}
if(findAccount != null)
{
textAccountId.setText(findAccount.getAccountId());
editAccountName.setText(findAccount.getAccountName());
editAccountDapt.setText(findAccount.getAccountDapt());
}
}
btnModify.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(findAccount == null)
return;
String acName = editAccountName.getText().toString();
String acDapt = editAccountDapt.getText().toString();
if( acName.isEmpty() || acDapt.isEmpty())
{
Toast.makeText(AccountModify.this, "모두 입력해주세요", Toast.LENGTH_SHORT).show();
return;
}
findAccount.setAccountName(acName);
findAccount.setAccountDapt(acDapt);
//DB에 저장
db.accountDao().update(findAccount);
Toast.makeText(AccountModify.this, "계정 수정 성공", Toast.LENGTH_SHORT).show();
finish();
}
});
}
}

View File

@@ -31,8 +31,8 @@ public class MainActivity extends AppCompatActivity {
mSpinner = findViewById(R.id.spinner_account);
Intent intent = new Intent(getApplicationContext(), test.class);
startActivity(intent);
//Intent intent = new Intent(getApplicationContext(), test.class);
//startActivity(intent);
//로그인
findViewById(R.id.button_login).setOnClickListener(new View.OnClickListener() {

View File

@@ -1,8 +1,13 @@
package com.qtagger;
import androidx.appcompat.app.AppCompatActivity;
import androidx.room.Room;
import android.os.Bundle;
import android.view.View;
import com.qtagger.Database.Account;
import com.qtagger.Database.AppDatabase;
public class test extends AppCompatActivity {
@@ -11,6 +16,18 @@ public class test extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
AppDatabase db = Room.databaseBuilder(this,AppDatabase.class,"AccountDB").allowMainThreadQueries().build();
findViewById(R.id.button3).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
for (int i = 1;i<=10;i++)
{
String str = Integer.toString(i) ;
db.accountDao().insert(new Account(str,str,str));
}
}
});
}
}

View File

@@ -8,6 +8,7 @@
tools:context=".Activity.AccountList">
<View
android:id="@+id/view"
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_marginTop="15dp"
@@ -44,20 +45,21 @@
<ScrollView
android:id="@+id/scrollview_AccountList"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_height="match_parent"
android:layout_marginTop="64dp"
android:layout_weight="1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintTop_toBottomOf="@+id/view"
tools:ignore="SpeakableTextPresentCheck">
<TableLayout
android:id="@+id/table_Account"
<LinearLayout
android:id="@+id/linearList"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="match_parent"
android:orientation="vertical">
</LinearLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Activity.AccountModify">
<View
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_marginTop="15dp"
android:background="#000000"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textViewAccountAccTitle" />
<TextView
android:id="@+id/textViewAccountAccTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="사용자 수정"
android:textAlignment="center"
android:textSize="24sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.utils.widget.ImageFilterButton
android:id="@+id/imageFilterButton_Back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:background="#FFFFFF"
android:minWidth="48dp"
android:minHeight="48dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/back_arrow_5821" />
<TextView
android:id="@+id/textView_AccountId"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="64dp"
android:layout_marginEnd="24dp"
android:paddingLeft="5dp"
android:textSize="16sp"
android:text="사용자 아이디"
android:gravity="center_vertical"
android:minHeight="48dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textViewAccountAccTitle" />
<EditText
android:id="@+id/textView_AccountName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="132dp"
android:layout_marginEnd="24dp"
android:hint="이름을 입력해주세요"
android:minHeight="48dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textViewAccountAccTitle" />
<EditText
android:id="@+id/textView_AccountDapt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="200dp"
android:layout_marginEnd="24dp"
android:hint="소속을 입력해주세요"
android:minHeight="48dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textViewAccountAccTitle" />
<Button
android:id="@+id/button_save"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_marginStart="16dp"
android:layout_marginTop="100dp"
android:layout_marginEnd="16dp"
android:text="수정"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView_AccountDapt" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -6,348 +6,12 @@
android:layout_height="match_parent"
android:background="#F1F3FA"
tools:context=".test">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="MissingConstraints">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TableLayout
android:id="@+id/tableLayout"
android:layout_width="fill_parent"
android:layout_height="150dp"
android:layout_marginStart="40dp"
android:layout_marginEnd="40dp"
android:background="@drawable/tablelayout_background"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TableRow
android:layout_width="0dp"
android:layout_height="wrap_content">
<TextView
android:layout_width="210dp"
android:layout_height="40dp"
android:text=" User001"
android:textColor="#000000"
android:textSize="24sp" />
<androidx.constraintlayout.utils.widget.ImageFilterButton
android:layout_width="52dp"
android:layout_height="32dp"
android:background="#00ff0000"
android:src="@drawable/edit_modify_icon_icons_com" />
<androidx.constraintlayout.utils.widget.ImageFilterButton
android:layout_width="32dp"
android:layout_height="32dp"
android:background="#00ff0000"
android:src="@drawable/trash_bin_icon_icons_com_67981" />
</TableRow>
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="40dp"
android:text=" 김철수"
android:textColor="#000000"
android:textSize="24sp" />
</TableRow>
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="40dp"
android:text=" 개발팀"
android:textColor="#000000"
android:textSize="24sp" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" />
</TableLayout>
<TableLayout
android:id="@+id/tableLayout2"
android:layout_width="fill_parent"
android:layout_height="150dp"
android:layout_marginStart="40dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="40dp"
android:background="@drawable/tablelayout_background"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tableLayout">
<TableRow
android:layout_width="0dp"
android:layout_height="wrap_content">
<TextView
android:layout_width="210dp"
android:layout_height="40dp"
android:text=" User001"
android:textColor="#000000"
android:textSize="24sp" />
<androidx.constraintlayout.utils.widget.ImageFilterButton
android:layout_width="52dp"
android:layout_height="32dp"
android:background="#00ff0000"
android:src="@drawable/edit_modify_icon_icons_com" />
<androidx.constraintlayout.utils.widget.ImageFilterButton
android:layout_width="32dp"
android:layout_height="32dp"
android:background="#00ff0000"
android:src="@drawable/trash_bin_icon_icons_com_67981" />
</TableRow>
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="40dp"
android:text=" 김철수"
android:textColor="#000000"
android:textSize="24sp" />
</TableRow>
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="40dp"
android:text=" 개발팀"
android:textColor="#000000"
android:textSize="24sp" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" />
</TableLayout>
<TableLayout
android:id="@+id/tableLayout3"
android:layout_width="fill_parent"
android:layout_height="150dp"
android:layout_marginStart="40dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="40dp"
android:background="@drawable/tablelayout_background"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tableLayout2">
<TableRow
android:layout_width="0dp"
android:layout_height="wrap_content">
<TextView
android:layout_width="210dp"
android:layout_height="40dp"
android:text=" User001"
android:textColor="#000000"
android:textSize="24sp" />
<androidx.constraintlayout.utils.widget.ImageFilterButton
android:layout_width="52dp"
android:layout_height="32dp"
android:background="#00ff0000"
android:src="@drawable/edit_modify_icon_icons_com" />
<androidx.constraintlayout.utils.widget.ImageFilterButton
android:layout_width="32dp"
android:layout_height="32dp"
android:background="#00ff0000"
android:src="@drawable/trash_bin_icon_icons_com_67981" />
</TableRow>
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="40dp"
android:text=" 김철수"
android:textColor="#000000"
android:textSize="24sp" />
</TableRow>
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="40dp"
android:text=" 개발팀"
android:textColor="#000000"
android:textSize="24sp" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" />
</TableLayout>
<TableLayout
android:id="@+id/tableLayout4"
android:layout_width="fill_parent"
android:layout_height="150dp"
android:layout_marginStart="40dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="40dp"
android:background="@drawable/tablelayout_background"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tableLayout2">
<TableRow
android:layout_width="0dp"
android:layout_height="wrap_content">
<TextView
android:layout_width="210dp"
android:layout_height="40dp"
android:text=" User001"
android:textColor="#000000"
android:textSize="24sp" />
<androidx.constraintlayout.utils.widget.ImageFilterButton
android:layout_width="52dp"
android:layout_height="32dp"
android:background="#00ff0000"
android:src="@drawable/edit_modify_icon_icons_com" />
<androidx.constraintlayout.utils.widget.ImageFilterButton
android:layout_width="32dp"
android:layout_height="32dp"
android:background="#00ff0000"
android:src="@drawable/trash_bin_icon_icons_com_67981" />
</TableRow>
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="40dp"
android:text=" 김철수"
android:textColor="#000000"
android:textSize="24sp" />
</TableRow>
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="40dp"
android:text=" 개발팀"
android:textColor="#000000"
android:textSize="24sp" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" />
</TableLayout>
<TableLayout
android:id="@+id/tableLayout5"
android:layout_width="fill_parent"
android:layout_height="150dp"
android:layout_marginStart="40dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="40dp"
android:background="@drawable/tablelayout_background"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tableLayout2">
<TableRow
android:layout_width="0dp"
android:layout_height="wrap_content">
<TextView
android:layout_width="210dp"
android:layout_height="40dp"
android:text=" User001"
android:textColor="#000000"
android:textSize="24sp" />
<androidx.constraintlayout.utils.widget.ImageFilterButton
android:layout_width="52dp"
android:layout_height="32dp"
android:background="#00ff0000"
android:src="@drawable/edit_modify_icon_icons_com" />
<androidx.constraintlayout.utils.widget.ImageFilterButton
android:layout_width="32dp"
android:layout_height="32dp"
android:background="#00ff0000"
android:src="@drawable/trash_bin_icon_icons_com_67981" />
</TableRow>
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="40dp"
android:text=" 김철수"
android:textColor="#000000"
android:textSize="24sp" />
</TableRow>
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="40dp"
android:text=" 개발팀"
android:textColor="#000000"
android:textSize="24sp" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" />
</TableLayout>
</LinearLayout>
</ScrollView>
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
tools:layout_editor_absoluteX="90dp"
tools:layout_editor_absoluteY="80dp" />
</androidx.constraintlayout.widget.ConstraintLayout>