0

my activity is load a grid view from xml file and the controls from other xml file

     public class ResultActivity extends AppCompatActivity {
    GridView gridview;

    ArrayList<String> arrayList;
    String ip, db, un, passwords;
    Connection connect;
    PreparedStatement stmt;
    ResultSet rs;
    Button TButton;
    @Override

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
         setContentView(R.layout.gridviews);

        TButton = (Button) findViewById(R.id.btnTrans);
        TButton.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v){
                Intent intentLoadNewActivity = new Intent(ResultActivity.this,MyResultsActivity.class);
                startActivity(intentLoadNewActivity);
            }
        });
  try {
            connect = CONN(un, passwords, db, ip);
            Statement statement = connect.createStatement();
            rs = statement.executeQuery(query);
            List<Map<String, String>> data = null;
            data = new ArrayList<Map<String, String>>();
            while (rs.next()) {
                Map<String, String> datanum = new HashMap<String, String>();
                datanum.put("A", "Patient Number: "+rs.getString("PatNumber"));
                datanum.put("B", "Welcome " + rs.getString("PatName"));
               // datanum.put("C","Transaction:" + rs.getString("trano"));

                data.add(datanum);
            }
           // String[] from = { "A", "B","C" };
            String[] from = { "A", "B" };
            int[] views = { R.id.txtPatNumber, R.id.txtpatName};
            final SimpleAdapter ADA = new SimpleAdapter(ResultActivity.this,

                    data, R.layout.patientdata, from, views);
            gridview.setAdapter(ADA);
        } catch (SQLException e) {
            e.printStackTrace();
        }
 }
4
Contributors
5
Replies
37
Views
1 Year
Discussion Span
Last Post by imchivaa
0

what i need is to move to other activity when click the button , which in the patientdata.Xml
and setContentView(R.layout.gridviews), Any Suggestion plzz??

1

Are you saying that setContentView(R.layout.gridviews) is where you get the NPE? Where is Rdefined. Is it null?

0

Paste the complete stack trace... It's hard to trace which line exactly throws the NPE.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.