Android - Problema 1 programa

 
Vista:

Problema 1 programa

Publicado por Carlos Diaz (1 intervención) el 10/03/2016 13:24:12
Hola Buenos dias , solicito ayuda sobre los 3 errores que me salen es mi primer programa que hago, y me ha costado encontrar en que me estoy equivocando

Saludos
Carlos Diaz

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
package hitesh.sqlapp;
 
import android.app.Activity;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.SimpleAdapter;
import android.widget.Toast;
 
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**
 * Created by Carlos on 11-02-2016.
 */
public class Clientes extends Activity {
    ConnectionClass connectionClass;
    ProgressBar pbbarc;
    ListView lstcli;
    String cliid;
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.clientes);
 
        connectionClass = new ConnectionClass();
        pbbarc = (ProgressBar) findViewById(R.id.pbbarc);
        pbbarc.setVisibility(View.GONE);
        lstcli = (ListView) findViewById(R.id.listcli);
        cliid = getIntent().getStringExtra("proid");
    }
 
    FillListc fillList = new FillListc();
    fillList.execute("");
 
    public class FillListc extends AsyncTask<String,String,String> {
        String a = "";
 
        List<Map<String, String>> prolistc = new ArrayList<Map<String, String>>();
 
        @Override
        protected void onPreExecute() {
 
            pbbarc.setVisibility(View.VISIBLE);
        }
 
        protected void onPostExecute(String r) {
            pbbarc.setVisibility(View.GONE);
            Toast.makeText(Clientes.this, r, Toast.LENGTH_SHORT).show();
 
            String[] from={"A","B","C"};
           // int[] views = {R.id.lblproid, R.id.lblproname,R.id.lblprodesc};
            final SimpleAdapter ADA = new SimpleAdapter(Clientes.this,
                    prolistc, R.layout.clientes, from,
                    views);
 
            lstcli.setAdapter(ADA);
 
            lstcli.setOnItemClickListener(new AdapterView.OnItemClickListener() {
 
                @Override
                public void onItemClick(AdapterView<?> arg0, View arg1,
                                        int arg2, long arg3) {
                    HashMap<String, Object> obj = (HashMap<String, Object>) ADA
                            .getItem(arg2);
                    cliid = (String) obj.get("A");
                    String proname = (String) obj.get("B");
                    // String prodesc = (String) obj.get("C");
                    // edtprodesc.setText(prodesc);
                    //  edtproname.setText(proname);
                    // qty.setText(qtys);
                }
            });
        }
 
        @Override
        protected String doInBackground(String... params) {
 
            try {
                Connection con = connectionClass.CONN();
                if (con == null) {
                    a = "Error in connection with SQL server";
                } else {
                    String query = "SELECT Codigo, Descripcion FROM dbo.SectoresPalm Order by Descripcion";
                    PreparedStatement ps = con.prepareStatement(query);
                    ResultSet rs = ps.executeQuery();
 
                    ArrayList<String> data1 = new ArrayList<String>();
                    while (rs.next()) {
                        Map<String, String> datanum = new HashMap<String, String>();
                        datanum.put("A", rs.getString("Codigo"));
                        datanum.put("B", rs.getString("Descripcion"));
                        // datanum.put("C", rs.getString("ProDesc"));
                       lstcli.add(datanum);
                    }
                    a = "Success";
                }
            } catch (Exception ex) {
               a  = "Error retrieving data from table";
            }
            return a;
        }
    }
 
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder