-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainActivity.java
More file actions
140 lines (115 loc) · 3.25 KB
/
Copy pathMainActivity.java
File metadata and controls
140 lines (115 loc) · 3.25 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
package com.example.sql;
import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends Activity implements OnClickListener {
EditText e;
EditText e1;
Button update;
Button view;
Button getin,delete,edit;
EditText row;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
e= (EditText) findViewById(R.id.et1);
e1 =(EditText) findViewById(R.id.et2);
update= (Button) findViewById(R.id.b1);
view= (Button) findViewById(R.id.b2);
row = (EditText) findViewById(R.id.row);
getin=(Button) findViewById(R.id.getinfo);
delete=(Button) findViewById(R.id.deleteent);
edit=(Button) findViewById(R.id.editent);
update.setOnClickListener(this);
view.setOnClickListener(this);
e1.setOnClickListener(this);
e.setOnClickListener(this);
row.setOnClickListener(this);
getin.setOnClickListener(this);
delete.setOnClickListener(this);
edit.setOnClickListener(this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
@Override
public void onClick(View v) {
switch(v.getId()){
case R.id.b1:
boolean works = true;
try{
String name =e.getEditableText().toString();
String hot = e1.getText().toString();
hot entry = new hot(MainActivity.this);
entry.open();
entry.createEntry(name,hot);
entry.close();
}catch(Exception e)
{
works=false;
String error = e.toString();
Dialog d =new Dialog(this);
d.setTitle("HECK noo");
TextView tv = new TextView(this);
tv.setText(error);
d.setContentView(tv);
d.show();
}finally{
if(works)
{
Dialog d =new Dialog(this);
d.setTitle("HECK YYAA");
TextView tv = new TextView(this);
tv.setText("success");
d.setContentView(tv);
d.show();
}
}
break;
case R.id.b2:
Intent i = new Intent("com.example.sql.sqlview");
startActivity(i);
break;
case R.id.getinfo:
String s=row.getText().toString();
long l = Long.parseLong(s);
hot hon = new hot(this);
hon.open();
String rename= hon.getName(l);
String rehot = hon.getHot(l);
hon.close();
e.setText(rename);
e1.setText(rehot);
break;
case R.id.editent:
String sname =e.getEditableText().toString();
String shot = e1.getText().toString();
String srow=row.getText().toString();
long lrow=Long.parseLong(srow);
hot ex= new hot(this);
ex.open();
ex.update(lrow, sname, shot);
ex.close();
break;
case R.id.deleteent:
String srow1=row.getText().toString();
long lrow1=Long.parseLong(srow1);
hot delete=new hot(this);
delete.open();
delete.deleteentry(lrow1);
delete.close();
break;
}
}
}