Thursday, June 30, 2011

Android kSoap2 web service parsing Data

Android kSoap2 web service Parsing Data
In this tutorial for Android ksoap2 web service . we can passing data through web service and store the data in web server.
how to read and parse JSON or XML, but another (pretty big) format is SOAP. In this post we will see how you make a application that reads and parses SOAP data into a Android application!
first we need ksoap2-android-assembly-2.4-jar file. download this jar file and put your workspace lib folder.

Download latest ksoap Jar File
Note: At the time of writing this the most recent version is 2.5.4 .
  • Just click the most recent version
  • search for the jar file with dependencies.
  • download it by right clicking the link "Raw file"
  • then clicking "Save as ...".
  • Save it inside your project folder so you can link it easily.
Note: add the jar file to the project. ( Project properties -> Java build path -> Add JAR's )
Download ksoap2 JAR File
Source code
package com.soap;
import java.io.*;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.AndroidHttpTransport;
import org.ksoap2.transport.HttpTransportSE;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.Toast;
public class Mainactivity extends Activity {
    ImageButton b;
     
    private final String NAMESPACE = "http://str7......com/";
    private final String METHOD_NAME = "InsertChild";
    private final String SOAP_ACTION = "http://str7..........com/InsertChild";
    private final String URL = "http://str7...........com/custodyapp.asmx";
   // protected static final String END_DOCUMENT =null;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
                 //   SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
                 ///  request.addProperty("ChildName","ijay");
                   SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
                    request.addProperty("ChildName","Vijay");
                    request.addProperty("GroupID","15");
                   request.addProperty("ParentID","15");
                   request.addProperty("Remarks","good");
                    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                      SoapEnvelope.VER11);
                    envelope.dotNet=true;
                    envelope.setOutputSoapObject(request);                                 .
                    HttpTransportSE  httpTransport = new HttpTransportSE(URL);
                    httpTransport.debug = true;
                    try {
                     httpTransport.call(SOAP_ACTION, envelope);
                     SoapObject result = (SoapObject) envelope.bodyIn;
                           Log.i("Result........................", result.toString());
                                                      
                    } catch (IOException e) {
                     // TODO Auto-generated catch block
                     e.printStackTrace();
                    } catch (XmlPullParserException e) {
                     // TODO Auto-generated catch block
                     e.printStackTrace();
                    } // This sends a soap
                   Log.i(envelope.bodyIn.toString(),"....................");
    }}

Tuesday, June 28, 2011

Custem calender with gridview in Android

Custem calender with gridview in Android
 Download source code

This is for android calender view in gridview.

this is usefull for while using grid calender view in your apps.


i hope it's help full for you. 
calendar_day_gridcell.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/calendar_button_selector">

    <Button
        android:id="@+id/calendar_day_gridcell"
        android:layout_gravity="center"
        android:textColor="#FFFFFF"
        android:background="@drawable/calendar_button_selector"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
    </Button>
   
    <TextView
        android:id="@+id/num_events_per_day"
        style="@style/calendar_event_style"
        android:layout_gravity="right"
        android:layout_width="10dip"
        android:layout_height="10dip">
    </TextView>
   
</RelativeLayout>








SimpleCalendarViewActivity.java

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;

import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.text.format.DateFormat;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;

public class SimpleCalendarViewActivity extends Activity implements OnClickListener
    {
        private static final String tag = "SimpleCalendarViewActivity";

        private ImageView calendarToJournalButton;
        private Button selectedDayMonthYearButton;
        private Button currentMonth;
        private ImageView prevMonth;
        private ImageView nextMonth;
        private GridView calendarView;
        private GridCellAdapter adapter;
        private Calendar _calendar;
        private int month, year;
        private final DateFormat dateFormatter = new DateFormat();
        private static final String dateTemplate = "MMMM yyyy";

        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState)
            {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.simple_calendar_view);

                _calendar = Calendar.getInstance(Locale.getDefault());
                month = _calendar.get(Calendar.MONTH) + 1;
                year = _calendar.get(Calendar.YEAR);
                Log.d(tag, "Calendar Instance:= " + "Month: " + month + " " + "Year: " + year);

                selectedDayMonthYearButton = (Button) this.findViewById(R.id.selectedDayMonthYear);
                selectedDayMonthYearButton.setText("Selected: ");

                prevMonth = (ImageView) this.findViewById(R.id.prevMonth);
                prevMonth.setOnClickListener(this);

                currentMonth = (Button) this.findViewById(R.id.currentMonth);
                currentMonth.setText(dateFormatter.format(dateTemplate, _calendar.getTime()));

                nextMonth = (ImageView) this.findViewById(R.id.nextMonth);
                nextMonth.setOnClickListener(this);

                calendarView = (GridView) this.findViewById(R.id.calendar);

                // Initialised
                adapter = new GridCellAdapter(getApplicationContext(), R.id.calendar_day_gridcell, month, year);
                adapter.notifyDataSetChanged();
                calendarView.setAdapter(adapter);
            }

        /**
         *
         * @param month
         * @param year
         */
        private void setGridCellAdapterToDate(int month, int year)
            {
                adapter = new GridCellAdapter(getApplicationContext(), R.id.calendar_day_gridcell, month, year);
                _calendar.set(year, month - 1, _calendar.get(Calendar.DAY_OF_MONTH));
                currentMonth.setText(dateFormatter.format(dateTemplate, _calendar.getTime()));
                adapter.notifyDataSetChanged();
                calendarView.setAdapter(adapter);
            }

        public void onClick(View v)
            {
                if (v == prevMonth)
                    {
                        if (month <= 1)
                            {
                                month = 12;
                                year--;
                            }
                        else
                            {
                                month--;
                            }
                        Log.d(tag, "Setting Prev Month in GridCellAdapter: " + "Month: " + month + " Year: " + year);
                        setGridCellAdapterToDate(month, year);
                    }
                if (v == nextMonth)
                    {
                        if (month > 11)
                            {
                                month = 1;
                                year++;
                            }
                        else
                            {
                                month++;
                            }
                        Log.d(tag, "Setting Next Month in GridCellAdapter: " + "Month: " + month + " Year: " + year);
                        setGridCellAdapterToDate(month, year);
                    }

            }

Monday, June 27, 2011

Android lazy image loader example

Android lazy image loader example


Suppose ,you have a list View in your activity where you have to download the data and corresponding images and show it in the list.

Generally if you download both the data and images once and after  downloading of data you will show it in the list which will take a longer duration particularly depends on net connectivity speed.

For Reducing the time ,first we download the text ie.,names,links except images .we will put the download links in a stack and we will download them after displaying the list-view by using late downloading of images.
First the list will show and images will show in their corresponding position in the list whenever it got downloaded exactly like android market application.
This will reduce the time and we can download as many items we want to show as like working of android market list view.





Thursday, June 9, 2011

Android wheel picker example

Android wheel picker example

Now you can with Android-Wheel  WheelPicker for Android:
Download Source Code Here

Android-Wheel: 
It comes with a handy ScrollListener for listen to touch events on the wheel component.


source code

package com.vijay;


import com.vijay.wheel.ArrayWheelAdapter;
import com.vijay.wheel.OnWheelChangedListener;
import com.vijay.wheel.OnWheelScrollListener;
import com.vijay.wheel.WheelView;

import android.app.Activity;
import android.os.Bundle;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends Activity
    {
        // TODO: Externalize string-array
        String wheelMenu1[] = new String[]{"name 1", "name 2", "name 3", "name 4", "name 5", "name 6","name 7","name 8","name 9"};
        String wheelMenu2[] = new String[]{"age 1", "age 2", "age 3"};
        String wheelMenu3[] = new String[]{"10", "20","30","40","50","60"};

        // Wheel scrolled flag
        private boolean wheelScrolled = false;

        private TextView text;
        private EditText text1;
        private EditText text2;
        private EditText text3;

        @Override
        public void onCreate(Bundle savedInstanceState)
            {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.main);

                initWheel1(R.id.p1);
                initWheel2(R.id.p2);
                initWheel3(R.id.p3);

                text1 = (EditText) this.findViewById(R.id.r1);
                text2 = (EditText) this.findViewById(R.id.r2);
                text3 = (EditText) this.findViewById(R.id.r3);
                text = (TextView) this.findViewById(R.id.result);
            }

        // Wheel scrolled listener
        OnWheelScrollListener scrolledListener = new OnWheelScrollListener()
            {
                public void onScrollStarts(WheelView wheel)
                    {
                        wheelScrolled = true;
                    }

                public void onScrollEnds(WheelView wheel)
                    {
                        wheelScrolled = false;
                        updateStatus();
                    }
            };

        // Wheel changed listener
        private final OnWheelChangedListener changedListener = new OnWheelChangedListener()
            {
                public void onChanged(WheelView wheel, int oldValue, int newValue)
                    {
                        if (!wheelScrolled)
                            {
                                updateStatus();
                            }
                    }
            };

        /**
         * Updates entered PIN status
         */
        private void updateStatus()
            {
                text1.setText(wheelMenu1[getWheel(R.id.p1).getCurrentItem()]);
                text2.setText(wheelMenu2[getWheel(R.id.p2).getCurrentItem()]);
                text3.setText(wheelMenu3[getWheel(R.id.p3).getCurrentItem()]);

                text.setText(wheelMenu1[getWheel(R.id.p1).getCurrentItem()] + " - " + wheelMenu2[getWheel(R.id.p2).getCurrentItem()] + " - " + wheelMenu3[getWheel(R.id.p3).getCurrentItem()]);
            }

        /**
         * Initializes wheel
         *
         * @param id
         *          the wheel widget Id
         */

        private void initWheel1(int id)
            {
                WheelView wheel = (WheelView) findViewById(id);
                wheel.setAdapter(new ArrayWheelAdapter<String>(wheelMenu1));
                wheel.setVisibleItems(2);
                wheel.setCurrentItem(0);
                wheel.addChangingListener(changedListener);
                wheel.addScrollingListener(scrolledListener);
            }

        private void initWheel2(int id)
            {
                WheelView wheel = (WheelView) findViewById(id);
                wheel.setAdapter(new ArrayWheelAdapter<String>(wheelMenu2));
                wheel.setVisibleItems(2);
                wheel.setCurrentItem(0);
                wheel.addChangingListener(changedListener);
                wheel.addScrollingListener(scrolledListener);
            }

        private void initWheel3(int id)
            {
                WheelView wheel = (WheelView) findViewById(id);

                wheel.setAdapter(new ArrayWheelAdapter<String>(wheelMenu3));
                wheel.setVisibleItems(2);
                wheel.setCurrentItem(0);
                wheel.addChangingListener(changedListener);
                wheel.addScrollingListener(scrolledListener);
            }

        /**
         * Returns wheel by Id
         *
         * @param id
         *          the wheel Id
         * @return the wheel with passed Id
         */
        private WheelView getWheel(int id)
            {
                return (WheelView) findViewById(id);
            }

        /**
         * Tests wheel value
         *
         * @param id
         *          the wheel Id
         * @param value
         *          the value to test
         * @return true if wheel value is equal to passed value
         */
        private int getWheelValue(int id)
            {
                return getWheel(id).getCurrentItem();
            }
    }

main.xml

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:background="@drawable/layout_bg">


    <LinearLayout
        android:layout_marginTop="24dp"
        android:layout_gravity="center_horizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">

        <com.vijay.wheel.WheelView
            android:id="@+id/p1"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content" />
        <com.vijay.wheel.WheelView
            android:id="@+id/p2"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content" />
        <com.vijay.wheel.WheelView
            android:id="@+id/p3"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content" />
    </LinearLayout>

    <LinearLayout
        android:orientation="horizontal"
        android:layout_gravity="center_horizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="24dp">
        <EditText
            android:id="@+id/r1"
            android:layout_width="100dip"
            android:layout_height="wrap_content"
            android:layout_marginTop="24dp"
            android:layout_gravity="center_horizontal"
            android:textSize="18sp"
            android:textColor="#000">
        </EditText>
        <EditText
            android:id="@+id/r2"
            android:layout_width="80dip"
            android:layout_height="wrap_content"
            android:layout_marginTop="24dp"
            android:layout_gravity="center_horizontal"
            android:textSize="18sp"
            android:textColor="#000">
        </EditText>
        <EditText
            android:id="@+id/r3"
            android:layout_width="80dip"
            android:layout_height="wrap_content"
            android:layout_marginTop="24dp"
            android:layout_gravity="center_horizontal"
            android:textSize="18sp"
            android:textColor="#000">
        </EditText>
    </LinearLayout>

    <TextView
        android:id="@+id/result"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="24dp"
        android:layout_gravity="center_horizontal"
        android:textSize="18sp"
        android:textColor="#FFF"
        android:text="Your choice">
    </TextView>
</LinearLayout>






Wednesday, June 8, 2011

App Inventor ..Create your own android apps

DOWNLOAD APP INVENTOR TUTORIAL

App Inventor  ..Create your own android apps


Add caption

App Inventor Setup

As you use App Inventor to build apps on your computer, your app will appear bit by bit on your connected Android phone or a running emulator. To make this happen you need to complete the following steps:

Set up your computer

System requirements:

Computer and operating system
  • Macintosh (with Intel processor): Mac OS X 10.5, 10.6
  • Windows: Windows XP, Windows Vista, Windows 7
  • GNU/Linux: Ubuntu 8+, Debian 5+
Browser
  • Mozilla Firefox 3.6 or higher
  • Apple Safari 5.0 or higher
  • Google Chrome 4.0 or higher
  • Microsoft Internet Explorer 7 or higher

Test your Java configuration

Your computer needs to run Java 6 (also known as Java 1.6). You can download Java from www.java.com.
Test your Java configuration by performing both of the following tests:
  1. Visit the Java test page. You should see a message that Java is working and that the version is Java 1.6.
  2. Run the AppInventor Java test by clicking on this link. This will check that your browser is properly configured to run Java, and that your computer can launch applications with Java Web Start.
App Inventor will not work on your computer if these tests do not succeed. Don't go on to try to use App Inventor until you've dealt with the issue.

After config app inventor in your pc.

Then click this URL http://appinventor.googlelabs.com or copy paste this url in your browser.

click My Project option then u can start your project

Before you can use App Inventor, you need to install some software on your computer. The software you need is provided in a package called App Inventor Setup. Follow the instructions for your operating system to do the installation.





Is Android the Future of Mobile Computing?

 Is Android the Future of Mobile Computing?






Devices like Apple’s iPhone and the various versions of Blackberry smartphones are revolutionizing computing. Phones and phone-like devices are increasingly blurring the lines between notebook computers, netbooks and phones. The mobile computing revolution is on!
One platform, however, truly stands out as a potential game changer. That platform is the Android platform from Google. Is Android the future of mobile computing? There is certainly a strong potential for Android to shape the future of mobile computing.
Android’s strength comes from its openness. The Android SDK is open source and the license governing Android itself allows any handset manufacturer to use and modify it. This allows Android to shape the future of mobile computing by making it available to any hardware manufacturer that wants to use it. This means that Android is likely to be the OS of choice for future mobile computing hardware like tablet PCs or e-book readers.
Android’s openness also applies to the selection of mobile carrier. This is one area where many users have been unhappy with Apple’s iPhone. Android is widely available which means that most wireless carriers have an Android handset available. Customers want choice. By giving them choice, Android positions itself as the future of mobile computing.
Android’s greatest strength, however, is its development kit. In the history of computing, the platforms that supported the application developers best became the clear winners. Failure to support application developers with robust tools killed the really Apple platform and IBM’s OS2. This is a mistake that Apple seems to be willing to repeat with the iPhone. The iPhone development tools are difficult to use and the application approval process seems terribly subjective at times. This makes iPhone application development unprofitable for many developers. In contrast, the Android development tools use Java and even C/C++. This allows developers to write applications for Android using languages they already know and use. Additionally, it allows them to use the tools they are already using such as Eclipse. The Android SDK also provides a very robust emulator so that application developers can test their Android applications without relying on physical hardware to do so. The future of mobile computing will largely be determined by the availability of the applications that end users want and need. In this regard, Android is a clear winner.
The biggest danger to Android’s dominance over the future of mobile computing is fragmentation. The ability of hardware vendors to extend Android without contributing their changes back to the Android project could lead to various incompatible versions of Android. To some extent, this has already happened as developers have had to struggle some to make their applications to support different hardware capabilities. This fragmentation of Android would make it harder for application developers to write code for Android. Since the support of application developers is crucial to the success of any computing platform, fragmentation could be a serious threat to Android as the future of mobile computing.
Is Android the future of mobile computing? I think the answer is that it certainly could be. Android’s open nature makes it possible for hardware developers to use it for whatever new devices they can imagine. Its SDK makes it easy for application developers to create the applications users want and need. Both factors make Android a strong contender for the shape of the future of mobile computing. However, there is a danger that hardware vendors will customize Android to the extent that the platform becomes fragmented. If this happens, it will be harder for application developers to write for Android and this could endanger its lead position as the future of mobile computing.



Monday, June 6, 2011

Android Text To Speech Example

Android Text To Speech Example

DOWNLOAD SOURCE CODE


Actually that’s the whole code.
You just need to create a TextToSpeech object.


this code text to speech simple example code


SOURCE CODE


public class MainActivity extends Activity implements OnInitListener {

    TextToSpeech textTalker;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Button tv=(Button)findViewById(R.id.button1);
       
      
        textTalker = new TextToSpeech(this, this);
       
        tv.setOnClickListener(new OnClickListener() {
           
            public void onClick(View v) {
                // TODO Auto-generated method stub
                 EditText et=(EditText)findViewById(R.id.editText1);
                 textTalker.speak(et.getText().toString(), TextToSpeech.SUCCESS, null);
            }
           
        });
    }

    @Override
    public void onDestroy() {
        if (textTalker != null) {
            textTalker.stop();
            textTalker.shutdown();
        }

        super.onDestroy();
    }

    public void onInit(int status) {
        // TODO Auto-generated method stub
       
    }
   
   
}

Saturday, June 4, 2011

Android Random Number Generation

Android Random Number Generation
DOWNLOAD SOURCE CODE

This for random number generation android .
                                    
source code

 @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Button btn=(Button)findViewById(R.id.btn);
        EditText edit=(EditText)findViewById(R.id.edit);
       
       
        btn.setOnClickListener(new OnClickListener() {
           
            public void onClick(View v) {
                // TODO Auto-generated method stub
               
                long tim = System.currentTimeMillis();
                Random random = new Random(tim);
                int RandomNumber = random.nextInt(100000);
                 EditText edit=(EditText)findViewById(R.id.edit);
                edit.setText(String.valueOf("xxx"+RandomNumber));
            }
        });
    }

Friday, June 3, 2011

XMLResource Parser With Custem Listiew From Local XML In Android.

XMLResource Parser With Custem Listiew From Local XML In Android.
DOWNLOAD SOURCE CODE


 Xml Resource parser from local xml in android

it's parsing data from localxml


 anylocation.xml
from xml foder

<?xml version="1.0" encoding="UTF-8"?>
<jointData>
    <city>
            <option value="">Any Location</option>
            <option value="1">Salem</option>
            <option value="2">Chennai</option>
            <option value="3">Kovai</option>
            <option value="4">Bangalore</option>
            <option value="5">Triandrum</option>
            <option value="6">Madurai</option>
            <option value="7">Salem</option>
            <option value="8">Chennai</option>
            <option value="9">Kovai</option>
            <option value="10">Bangalore</option>
            <option value="11">Triandrum</option>
            <option value="12">Madurai</option>
          
    </city></jointData>



XMLResourceActivity.java


import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.XmlResourceParser;
import android.net.Uri;
import android.os.Bundle;
import android.provider.SyncStateContract.Columns;
import android.text.Html;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import android.widget.ArrayAdapter;

import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.TextView;

public class XMLResourceActivity extends Activity{
    LocationStruct location;
    ArrayList<LocationStruct> locationList=new ArrayList<LocationStruct>();
    private ListView list;
    public void onCreate(Bundle bundle){
        super.onCreate(bundle);
        setContentView(R.layout.listview);
       
       
        try {
            getData();
        } catch (XmlPullParserException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
   
    public void getData() throws XmlPullParserException, IOException{
        HotelArrayAdapter htlAdapt ;
        //ArrayList<String> todoItems = new ArrayList<String>();
XmlResourceParser todolistXml = getResources().getXml(R.xml.anylocation);
       
        int eventType = -1;
         while (eventType != XmlPullParser.END_DOCUMENT)
         {
             if(eventType == XmlPullParser.START_TAG) {
                 String strNode = todolistXml.getName();
                 if (strNode.equals("option")) {
                      location=new LocationStruct();
                     String str=todolistXml.getAttributeValue(null, "value").trim();
                     String cit=todolistXml.nextText().trim();
                     location.setValue(str);
                     location.setCity(cit);
                     locationList.add(location);
                 }
             }
           
                 try {
                    eventType = todolistXml.next();
                } catch (XmlPullParserException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
        }
 list=(ListView)findViewById(R.id.listView1);

     htlAdapt = new HotelArrayAdapter(this, android.R.layout.simple_list_item_1, locationList);
     list.setAdapter(htlAdapt);
   
    }
    public class HotelArrayAdapter extends ArrayAdapter<LocationStruct> {

        private ArrayList<LocationStruct> summaryitems =new ArrayList<LocationStruct>();
        private Context ctx1;
       
        public HotelArrayAdapter(Context context, int textViewResourceId,ArrayList<LocationStruct> summaryitems)
        {
        super(context, textViewResourceId, summaryitems);
        this.summaryitems = summaryitems;
        this.ctx1 = context;
        }
        @Override
        public View getView(int position, View convertView, ViewGroup parent)
        {
        View v = convertView;
        if (v == null)
        {
        LayoutInflater vi = (LayoutInflater) getContext().getSystemService(
                        Context.LAYOUT_INFLATER_SERVICE);
        v = vi.inflate(R.layout.location, null);
        }
        final LocationStruct o = summaryitems.get(position);
           
        if (o != null) {
        TextView dname = (TextView) v.findViewById(R.id.textView1);
        RadioButton select=(RadioButton)v.findViewById(R.id.select_btn);
        //Button btn=(Button)v.findViewById(R.id.select_btn);
        Log.i("city", "city===========  "+o.getCity());
        Log.i("city", "city===========>>>>>>>>>>  "+o.getValue());
           
              dname.setText(o.getCity());         
                 
                  
             
        }      
             return v;
        }
        }
}





Check out this may be help you

Related Posts Plugin for WordPress, Blogger...