saving data on server in android



Step 5:
Create an new class named UserData.This is the bean class which handles the name and age data enter by the user.This class contains getters and setters method for name and age variables.




Step 6:
Create another Activity “List_Name_Age” with layout list_name_age.This activity shows the data enter by the user     in the form of list when user click on ViewData button.
As I have to show the data to the user in the form of Custom List view hence create another layout which handles the custom ListView as:


Now add the following code to List_Name_Age.java:

In this I have defined an custom adapter for the data to be showed to the user in the form ListView.  

List_Name_Age.java
publicclass List_Name_Age extends Activity implements OnItemClickListener{

       String[] items;
       TextView selection;
       ListView listView;
       //get the list of data obtain from the server
       ArrayList<UserDetail>user=MainActivity.user;
      
       @Override
       publicvoid onCreate(Bundle icicle) {
              super.onCreate(icicle);
              setContentView(R.layout.list__name__age);
       //obtain an reference to the ListView defined in list__name_age xml file.
              listView=(ListView)findViewById(R.id.list);
              //create an custom adapter
       //pass data into another class that handles the data obtained from server
              //list_detail is the layout file which I have created for custom layout
              CustomListViewAdapter adapter=new CustomListViewAdapter(List_Name_Age.this,R.layout.list_detail,user);
              //set above adapter for the referenced listview
listView.setAdapter(adapter);
listView.setOnItemClickListener(this);
listView.setClickable(false);

       }

       publicvoid onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
              // TODO Auto-generated method stub
             
       }
}


Now I am going to create CustomListViewAdapter class,which override the ListView getView() method.Hence create an new class inside project src folder:

 continue reading article here :






No comments:

Post a Comment