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;

    protected void onCreate(Bundle savedInstanceState) {

        TButton = (Button) findViewById(;
        TButton.setOnClickListener(new View.OnClickListener(){
            public void onClick(View v){
                Intent intentLoadNewActivity = new Intent(ResultActivity.this,MyResultsActivity.class);
  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 ( {
                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"));

           // String[] from = { "A", "B","C" };
            String[] from = { "A", "B" };
            int[] views = {,};
            final SimpleAdapter ADA = new SimpleAdapter(ResultActivity.this,

                    data, R.layout.patientdata, from, views);
        } catch (SQLException e) {
Re: java.lang.NullPointerException 80 80

It would help if you told us which line throws the NPE, we're not mind readers

Re: java.lang.NullPointerException 80 80

As I read I see you could set breakpoints at and before the failing line of code to examine why that line or call fails.

I'm running into new programmers that don't use all the tools.

Re: java.lang.NullPointerException 80 80

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??

Re: java.lang.NullPointerException 80 80

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

Re: java.lang.NullPointerException 80 80

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.