Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8075801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:06:36+00:00 2026-06-05T15:06:36+00:00

This is my gridview.java class public class TextGridActivity extends Activity { String[] _cataId=new String[100]

  • 0

This is my gridview.java class

public class TextGridActivity extends Activity {

String[] _cataId=new String[100] ;
String[] _cataName=new String[100];
  String[] _cataDes=new String[100];
  String[] _cataCode=new String[100];
      int num,k=0;
         int len=10;
      String[] temp ;
DataAdapter mAdapter;

GridView gridView;
private static String SOAP_ACTION = "http://tempuri.org/GetItemCategory";

 private static String NAMESPACE = "http://tempuri.org/";

     String METHOD_NAME = "GetItemCategory";



 String res="";
  private static String URL = "http://10.0.2.2:63395/Service1.asmx";

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

fillTitle();

    createViews();
}

    public void createViews()
      { 

         mAdapter = new DataAdapter(this,_cataId,_cataName,_cataDes,_cataCode,len);
      GridView gridview = (GridView) findViewById(R.id.gridview);  

    gridview.setAdapter(mAdapter);}
//method for soap call
       public void fillTitle(){
       SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.dotNet = true;
    envelope.setOutputSoapObject(request);
    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
    try {

     androidHttpTransport.call(SOAP_ACTION, envelope);
     KvmSerializable response = (KvmSerializable)envelope.bodyIn;

    res= response.getProperty(0).toString();
    Toast.makeText(this, res,Toast.LENGTH_LONG).show();

    String delimiter = ";";
      temp= res.split(delimiter);


    for(int i=0;i<len; i++)
    {
        _cataId[i]=temp[i].substring(29);
    //Toast.makeText(this, _cataId[i],Toast.LENGTH_LONG).show();

        _cataName[i]=temp[i+1].substring(9);
        //Toast.makeText(this, _cataName[i],Toast.LENGTH_LONG).show();

        _cataDes[i]=temp[i+2].substring(9);
        //Toast.makeText(this, _cataDes[i],Toast.LENGTH_LONG).show();

        _cataCode[i]=temp[i+3].substring(10);
        //Toast.makeText(this, _cataCode[i],Toast.LENGTH_LONG).show();

     i=i+4;



    }


} 
    catch (Exception e) {

    Toast.makeText(this, e.toString(),
    Toast.LENGTH_LONG).show();
    } }
    }

this is my DataAdapter.java class

public class DataAdapter extends BaseAdapter
{                  
       Context mContext;

      private String[] _cataId ;
     private  String[] _cataName;
      private String[] _cataDes;
      private String[] _cataCode;
       int len;

     public DataAdapter(Context mContext, String [] cataId, String [] cataName, String[] cataDes, String[] cataCode,int len) {

         super();
          this.mContext=mContext;
         this._cataId=cataId;
         this._cataName = cataName;
         this._cataDes = cataDes;
         this._cataCode = cataCode;
           this.len = len;
         }

       private LayoutInflater mInflater;
       public DataAdapter(Context c)
       {
              mContext=c;
              mInflater = LayoutInflater.from(c);
       }
       public int getCount()
       {
              return len;
       }


       public Object getItem(int position)
       {


           return  position;

       }


    public long getItemId(int position)
       {
              return position;
       }


       public View getView(int position, View convertView, ViewGroup parent)
       {
              ViewHolder holder=null;
              if(convertView==null)
              {
                     convertView = mInflater.inflate(R.layout.customgrid, null);
                     holder = new ViewHolder();
                     holder.txtId=(TextView)convertView.findViewById(R.id.txtId);
                    // holder.txtId.setPadding(30, 10,10 , 10);
                     holder.txtName=(TextView)convertView.findViewById(R.id.txtName);
                    //holder.txtName.setPadding(30, 10, 10, 10);
                     holder.txtDes=(TextView)convertView.findViewById(R.id.txtDes);
                   // holder.txtDes.setPadding(30, 10, 10, 10);
                     holder.txtCode=(TextView)convertView.findViewById(R.id.txtCode);
                   // holder.txtCode.setPadding(30, 10, 10, 10);
                     if(position==0)
                     {                             
                           convertView.setTag(holder);
                     }
              }
              else
              {
                     holder = (ViewHolder) convertView.getTag();
              }
              holder.txtId.setText(_cataId[position]);
              holder.txtName.setText(_cataName[position]);
              holder.txtDes.setText(_cataDes[position]);
              holder.txtCode.setText(_cataCode[position]);

              return convertView;
       }
       static class ViewHolder
       {        

            TextView txtId;        
              TextView txtName; 
              TextView txtDes;
            TextView txtCode;
       }
}

the data is coming in the res variable.and it is delimited by (;) . i have toasted all the data and its going in ,_cataId,_cataName,_cataDes,_cataCode and is toasted to ensure its coming or not.

now my problem is im geeting force close on CreateViews() method.. in that madapter used n grid is clledd. plz tell me what im doing wrong while calling this method

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T15:06:38+00:00Added an answer on June 5, 2026 at 3:06 pm

    you get ANR since the communication is on the UI thread. as of android 4 .

    for all long (or unknown time) operations , use them on a thread that is not the UI thread , and update the UI thread only when needed.

    read this for more info:

    http://developer.android.com/resources/articles/painless-threading.html

    in order to avoid it ,you can use strict mode:

    http://developer.android.com/reference/android/os/StrictMode.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to java and android. i don't understand this code gridview.setOnItemClickListener(new OnItemClickListener() {
How to Solve java.lang.StackOverflowError from following Code? My Code is:- public class main extends
I have this gridview: <div class=content> <asp:GridView ID=DocumentGrid runat=server AutoGenerateColumns=False OnRowCommand=DocumentGrid_RowCommand > <Columns> <asp:BoundField
So I have this gridview, inside the gridview I have this template field, and
hi I have this gridview like this. <asp:DropDownList ID=triggerDropDown runat=server AutoPostBack=true onselectedindexchanged=triggerDropDown_SelectedIndexChanged> <asp:GridView ID=myGridView
I have a gridview data and this gridview have subgrid too. in the first
In asp.net I use like this: gridView_Desti.Columns[CODE_DEST].Caption = (string) HttpContext.GetGlobalResourceObject(Client, Code_Dest); How can I
I'd like to right align this gridview so that it's flush against the right
In my web page i used a gridview. In this gridview it shows a
I have a gridview I created using this tutorial GridView Android , which works

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.