-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathListOfItems3.java
More file actions
98 lines (90 loc) · 3.35 KB
/
Copy pathListOfItems3.java
File metadata and controls
98 lines (90 loc) · 3.35 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
package com.example.android.break2;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;
public class ListOfItems3 extends AppCompatActivity {
Controller obj=new Controller();
public static String nameOfItem;
String[] nameArray =new String[100];
ListView listView;
int active=0;
public static int Listitem3_active=0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list_of_items);
Bundle info = getIntent().getExtras();
active=info.getInt("type");
if(active==1) {
try {
nameArray = setnames(obj.getMostWished());//send resultset in parameter
} catch (SQLException e) {
e.printStackTrace();
}
}
else if(active==2)
{
try {
nameArray = setnames(obj.getMostViewed());//send resultset in parameter
} catch (SQLException e) {
e.printStackTrace();
}
}
else if(active==3)
{
try {
nameArray = setnames(obj.getMostRated());//send resultset in parameter
} catch (SQLException e) {
e.printStackTrace();
}
}
else
{
try {
nameArray = setnames(obj.getNewReales());//send resultset in parameter
} catch (SQLException e) {
e.printStackTrace();
}
}
Customlistadapter Names = new Customlistadapter(this, nameArray);
listView = (ListView) findViewById(R.id.lv);
listView.setAdapter(Names);
listView.setOnItemClickListener(
new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String item = String.valueOf(parent.getItemAtPosition(position));
Toast.makeText(ListOfItems3.this, item, Toast.LENGTH_LONG).show();
//positions starts from zero
if (position <= 100) {
//code specific to any list item
nameOfItem=nameArray[position];
Intent myIntent = new Intent(view.getContext(), ViewMovie.class);
Listitem3_active++;
startActivityForResult(myIntent, 0);
}
//to do set the rest of postions
}
});
}
public String[] setnames(ResultSet name) throws SQLException {
int i=0;
Vector<String> vec=new Vector<>();
while(name!=null&&name.next())
{
vec.add( name.getString(1));
i++;
}
String[]Names=new String[vec.size()];
for(int j=0;j<vec.size();j++)
Names[j]= vec.get(j);
return Names;
}
}