Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugged code for TODO App java #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion app/src/main/java/com/example/todoappjava/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ private void addTodo() {
if(isSuccess){
Toast.makeText(this, "Todo added successfully!", Toast.LENGTH_SHORT).show();
loadTodos();
etTodo.getText().clear(); // Text is now clearing in edit text after successful save
} else {
Toast.makeText(this, "Something went wrong!", Toast.LENGTH_SHORT).show();
}
Expand All @@ -69,7 +70,7 @@ private void loadTodos() {
}

private void initViews() {
rvTodos = findViewById(R.id.rvTodos);
rvTodos = findViewById(R.id.tvTodoText);
etTodo = findViewById(R.id.etTodo);
btnAddTodo = findViewById(R.id.btnAddTodo);
}
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/java/com/example/todoappjava/TodoAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@ public int getItemCount() {

class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {

private TextView tvTodoId, tvTodoText;
private ImageButton btnDelete;
private final TextView tvTodoId;
private final TextView tvTodoText;

public ViewHolder(@NonNull View itemView) {
super(itemView);
tvTodoText = itemView.findViewById(R.id.tvTodoText);
btnDelete = itemView.findViewById(R.id.btnDelete);
tvTodoId= itemView.findViewById(R.id.tvTodoId); // Id is corrected.
ImageButton btnDelete = itemView.findViewById(R.id.btnDelete);

btnDelete.setOnClickListener(this);
}
Expand Down
170 changes: 0 additions & 170 deletions app/src/main/res/drawable/ic_launcher_background.xml

This file was deleted.

2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
tools:context=".MainActivity">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvTodos"
android:id="@+id/tvTodoText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
Expand Down
5 changes: 0 additions & 5 deletions app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml

This file was deleted.

5 changes: 0 additions & 5 deletions app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml

This file was deleted.

Binary file removed app/src/main/res/mipmap-hdpi/ic_launcher.webp
Binary file not shown.
Binary file removed app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
Binary file not shown.
Binary file removed app/src/main/res/mipmap-mdpi/ic_launcher.webp
Binary file not shown.
Binary file removed app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
Binary file not shown.
Binary file removed app/src/main/res/mipmap-xhdpi/ic_launcher.webp
Binary file not shown.
Binary file removed app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
Binary file not shown.
Binary file removed app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
Binary file not shown.
Binary file not shown.
Binary file removed app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
Binary file not shown.
Binary file not shown.