daily pastebin goal
18%
SHARE
TWEET

Untitled

a guest Jan 23rd, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class MainA extends AppCompatActivity {
  2.  
  3.     protected void onCreate(@Nullable Bundle savedInstanceState) {
  4.         super.onCreate(savedInstanceState);
  5.         setContentView(R.layout.activity_main);
  6.     }
  7.  
  8.     public void listviewButtonClicked(View view) {
  9.         //System.out.println("VIEW clicked!");
  10.         Intent intent2 = new Intent(this, PickTodoA.class);
  11.         intent2.putExtra("pickordelete", false);
  12.         startActivity(intent2);
  13.     }
  14.  
  15.     public void createButtonClicked(View view) {
  16.         //System.out.println("CREATE clicked!");
  17.         Intent intent = new Intent(this, CreateA.class);
  18.         startActivity(intent);
  19.     }
  20.  
  21.     public void deleteButtonClicked(View view) {
  22.         //System.out.println("CREATE clicked!");
  23.         Intent intent4 = new Intent(this, PickTodoA.class);
  24.         intent4.putExtra("pickordelete", true);
  25.         startActivity(intent4);
  26.     }
  27.  
  28.  
  29. }
  30. [12:40 PM] PER: package com.example.myapplication;
  31.  
  32. import android.content.Intent;
  33. import android.os.Bundle;
  34. import android.support.annotation.Nullable;
  35. import android.support.v7.app.AppCompatActivity;
  36. import android.view.View;
  37. import android.widget.AdapterView;
  38. import android.widget.ArrayAdapter;
  39. import android.widget.ListView;
  40.  
  41. public class PickTodoA extends AppCompatActivity {
  42.     @Override
  43.     protected void onCreate(@Nullable Bundle SavedInstanceState) {
  44.         super.onCreate(SavedInstanceState);
  45.         setContentView(R.layout.activity_pick_todo);
  46.         ListView listView = (ListView) findViewById(R.id.listView);
  47.         listView.setAdapter(new ArrayAdapter<Data.ToDo>(this,android.R.layout.simple_list_item_1,Data.todos));
  48.  
  49.         listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  50.             @Override
  51.             public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
  52.                 Data.ToDo clickedTodo = Data.todos.get(position);
  53.                 boolean chioce = getIntent().getBooleanExtra("pickordelete", false);
  54.                 System.out.println(clickedTodo);
  55.                 if (chioce == false){
  56.                     System.out.println("PICK");
  57.                     Intent intent5 = new Intent(PickTodoA.this, ViewTodoA.class);
  58.                     intent5.putExtra("todoindex",position);
  59.                     intent5.putExtra("pickordelete2",false);
  60.                     startActivity(intent5);
  61.                 }
  62.                 else
  63.                 {
  64.                     System.out.println("DELE");
  65.                     Intent intent3 = new Intent(PickTodoA.this, ViewTodoA.class);
  66.                     intent3.putExtra("todoindex",position);
  67.                     intent3.putExtra("pickordelete2",true);
  68.                     startActivity(intent3);
  69.                 }
  70.  
  71.             }
  72.         });
  73.     }
  74. }
  75. [12:41 PM] PER: public class ViewTodoA extends AppCompatActivity {
  76.  
  77.     TextView Title_text;
  78.     Button del_button;
  79.     int pos;
  80.  
  81.     protected void onCreate(@Nullable Bundle SavedInstanceState) {
  82.         super.onCreate(SavedInstanceState);
  83.         setContentView(R.layout.activity_delete_todo);
  84.         boolean chioce = getIntent().getBooleanExtra("pickordelete2", false);
  85.         Title_text = (TextView) findViewById(R.id.textView_data1);
  86.         pos = getIntent().getIntExtra("todoindex", 0);
  87.         Data.ToDo object = Data.todos.get(pos);
  88.         del_button = (Button) findViewById(R.id.del_button);
  89.         if (chioce == false) {
  90.             del_button.setVisibility(View.GONE);
  91.         } else {
  92.             del_button.setVisibility(View.VISIBLE);
  93.         }
  94.  
  95.         Title_text.setText(getString(R.string.title_name) + object.title.toString());
  96.     }
  97.  
  98.     public void deleteButtonClicked2(View view) {
  99.         new AlertDialog.Builder(ViewTodoA.this)
  100.  
  101.                 .setTitle(R.string.Delete_todo)
  102.                 .setMessage(R.string.really_want_to_delete)
  103.                 .setPositiveButton(R.string.YES, new DialogInterface.OnClickListener() {
  104.                             public void onClick(DialogInterface dialog, int which) {
  105.                                 //delete
  106.                                 Data.todos.remove(pos);
  107.                                 Intent intent8 = new Intent(ViewTodoA.this, MainA.class);
  108.                                 startActivity(intent8);
  109.                             }
  110.                         }
  111.                 ).setNegativeButton(R.string.NO, new DialogInterface.OnClickListener() {
  112.                     public void onClick(DialogInterface dialog, int which) {
  113.                         //not delete
  114.                     }
  115.  
  116.                 }
  117.  
  118.         ).show();
  119.  
  120.     }
  121. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top