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

  • SEARCH
  • Home
  • 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 8246101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:23:52+00:00 2026-06-07T22:23:52+00:00

I am trying to get the data from the webservice and create dynamic custom

  • 0

I am trying to get the data from the webservice and create dynamic custom fields according to the response from the webservice. Then the user will fill the fields and then after clicking the upload button it will send the data from the dynamic custom fields to the webservice and then start to upload. I wonder that how can I get the data from the custom fields because they are created dynamically I can not reach them. Here is my code. Here is my picture that I created the fields after getting the response from the webservice I need your help.

enter image description here

package com.isoft.uploader;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Hashtable;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONObject;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;


import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.ScrollView;
import android.widget.TextView;

public class UploaderActivity extends Activity 
{
ArrayList <Response> WebData= new ArrayList<Response>();
public static final int SELECT_VIDEO=1;
public static final String TAG="UploadActivity";
String path="";
final String NAMESPACE = "http://tempuri.org/";
final String SERVICEURL = "http://192.168.10.177/androidws/isandroidws.asmx";
final String METHOD_NAME1="OzelVeriAlanlariniGetir";
final String METHOD_NAME="KullaniciGiris";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    Button enter=(Button)findViewById(R.id.Enter);
    final EditText username=(EditText)findViewById(R.id.username);
    final EditText password=(EditText)findViewById(R.id.password);
    final  AlertDialog ad=new AlertDialog.Builder(this).create();
    enter.setOnClickListener(new View.OnClickListener() 
    {
        @Override
        public void onClick(View arg0) 
        {
            // TODO Auto-generated method stub
            //request code for Webservice
            SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
            //sending the username to the webservice
            request.addProperty("kullaniciAdi",username.getText().toString());
            //sending the password to the webservice
            request.addProperty("password",password.getText().toString());
            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.dotNet = true;
            //Putting the request in an envelope
            envelope.setOutputSoapObject(request);
            HttpTransportSE transport = new HttpTransportSE(SERVICEURL);
            Object response = null;
            try
            {
                 transport.call("http://tempuri.org/"+METHOD_NAME, envelope);
                 //getting the response from the webservice
                 response= envelope.getResponse();
            }
            catch(Exception exception)
            {
                exception.printStackTrace();
            }//end of catch
            if(response!=null && Integer.parseInt(response.toString()) != 0)
            {
                openGaleryVideo();
            }//end of if
            else
            {
                ad.setMessage("Lütfen Kullanıcı Adınızı ve Şifrenizi Kontrol Ediniz.");
                ad.show();  
            }//end of else
        }//end of onClick method    
    });//end of OnclickListener method
}//end of onCreate method
public void openGaleryVideo()
{
    Intent intent=new Intent();
    intent.setType("video/*");
    intent.setAction(Intent.ACTION_GET_CONTENT);
    startActivityForResult(Intent.createChooser(intent, "Select Video"),SELECT_VIDEO);
}//end of openGaleryVideo method

public String getPath(Uri uri)
{   
    String[] projection = { MediaStore.Video.Media.DATA};
    Cursor cursor = managedQuery(uri, projection, null, null, null);
    int column_index = cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATA);
    cursor.moveToFirst();
    return cursor.getString(column_index);
}//end of getPath method

//Response Class
public class Response
{
    int Id;
    String Name;
    String Type;
    String Value;
    String DefaultValue;
    int Flag;
    int Index;
}//end of Response class

//onActivityResult
@SuppressWarnings("unused")
public void onActivityResult(int requestCode, int resultCode, Intent data) 
{
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == RESULT_OK)
    {
        if (requestCode == SELECT_VIDEO) 
        {
            Uri videoUri = data.getData();
            path=getPath(videoUri);
            ScrollView scroll = new ScrollView(this);
            LinearLayout layout=new LinearLayout(this);
            layout.setOrientation(LinearLayout.VERTICAL);
            layout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); 
            scroll.addView(layout,new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
            setContentView(scroll);             
            SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME1);
            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.dotNet = true;
            //İsteğimizi zarf'a koyuyoruz
            envelope.setOutputSoapObject(request);
            HttpTransportSE transport = new HttpTransportSE(SERVICEURL);
            final  AlertDialog adr=new AlertDialog.Builder(this).create();
            Object response1=null;
            try
            {
                 transport.call("http://tempuri.org/"+METHOD_NAME1, envelope);
                 //getting the response from the webservice
                 response1 =envelope.getResponse();
                 JSONArray jArray= new JSONArray(response1.toString());
                 for(int i=0;i<jArray.length();i++)
                 {
                     JSONObject json_data= jArray.getJSONObject(i);
                     Response result= new Response();
                     result.Id= json_data.getInt("Id");
                     result.Name= json_data.getString("Name");
                     result.Type= json_data.getString("Type");
                     result.Value=json_data.getString("Value");
                     result.DefaultValue=json_data.getString("DefaultValue");
                     result.Flag=json_data.getInt("Flag");
                     result.Index=json_data.getInt("Index");
                     WebData.add(i,result);
                 }//end of for loop     
            }//end of try 
            catch(Exception exception)
            {
                exception.printStackTrace();
            }//end of catch

            for(int j=0;j<WebData.size();j++)
            {
                TextView t= new TextView(this);
                t.setText(WebData.get(j).Name);
                layout.addView(t);
                if("Type"=="datetime")
                {
                    EditText datetime= new EditText(this);
                    datetime.setId(j);
                    SimpleDateFormat sdf = new SimpleDateFormat( "yyyy/MM/dd" ); 
                    datetime.setText(sdf.format( new Date()));
                    layout.addView(datetime);

                }//end of if

                else if("Type"=="int")
                {
                    EditText integer= new EditText(this);
                    layout.addView(integer);
                }//end of else if
                else
                {
                    EditText nvarchar= new EditText(this);
                    layout.addView(nvarchar);
                }//end of else 

            }//end of for loop
            Button button= new Button(this);
            button.setClickable(true);
            button.setText("Yükle");
            layout.addView(button);
            button.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View arg0)
                {
                    // TODO Auto-generated method stub

                }
            });
        }//end of If request code
    }//end of If result code
}//end of onActivityResult
}//end of main
  • 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-07T22:23:53+00:00Added an answer on June 7, 2026 at 10:23 pm

    If I understood right, your problem is getting the data from the dynamically created fields. You could solve it by saving the dynamically created EditText in your class.

    Here’s your code saving the fields (I didn’t check the syntax). I’ve marked the changed blocks with //BUBBLE comment.

    package com.isoft.uploader;
    
    import java.text.SimpleDateFormat;
    import java.util.ArrayList;
    import java.util.Date;
    import java.util.Hashtable;
    import java.util.List;
    
    import org.json.JSONArray;
    import org.json.JSONObject;
    import org.ksoap2.SoapEnvelope;
    import org.ksoap2.serialization.SoapObject;
    import org.ksoap2.serialization.SoapSerializationEnvelope;
    import org.ksoap2.transport.HttpTransportSE;
    
    
    import android.app.Activity;
    import android.app.AlertDialog;
    import android.content.Intent;
    import android.database.Cursor;
    import android.net.Uri;
    import android.os.Bundle;
    import android.provider.MediaStore;
    import android.view.View;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.ScrollView;
    import android.widget.TextView;
    
    public class UploaderActivity extends Activity 
    {
      ArrayList <Response> WebData= new ArrayList<Response>();
      public static final int SELECT_VIDEO=1;
      public static final String TAG="UploadActivity";
      String path="";
      final String NAMESPACE = "http://tempuri.org/";
      final String SERVICEURL = "http://192.168.10.177/androidws/isandroidws.asmx";
      final String METHOD_NAME1="OzelVeriAlanlariniGetir";
      final String METHOD_NAME="KullaniciGiris";
    
      // BUBBLE
      private List<EditText> dynaFields = null;
    
      /** Called when the activity is first created. */
      @Override
        public void onCreate(Bundle savedInstanceState) 
        {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
          Button enter=(Button)findViewById(R.id.Enter);
          final EditText username=(EditText)findViewById(R.id.username);
          final EditText password=(EditText)findViewById(R.id.password);
          final  AlertDialog ad=new AlertDialog.Builder(this).create();
          enter.setOnClickListener(new View.OnClickListener() 
              {
              @Override
              public void onClick(View arg0) 
              {
              // TODO Auto-generated method stub
              //request code for Webservice
              SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
              //sending the username to the webservice
              request.addProperty("kullaniciAdi",username.getText().toString());
              //sending the password to the webservice
              request.addProperty("password",password.getText().toString());
              SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
              envelope.dotNet = true;
              //Putting the request in an envelope
              envelope.setOutputSoapObject(request);
              HttpTransportSE transport = new HttpTransportSE(SERVICEURL);
              Object response = null;
              try
              {
              transport.call("http://tempuri.org/"+METHOD_NAME, envelope);
              //getting the response from the webservice
              response= envelope.getResponse();
              }
              catch(Exception exception)
              {
                exception.printStackTrace();
              }//end of catch
              if(response!=null && Integer.parseInt(response.toString()) != 0)
              {
                openGaleryVideo();
              }//end of if
              else
              {
                ad.setMessage("Lütfen Kullanıcı Adınızı ve Şifrenizi Kontrol Ediniz.");
                ad.show();  
              }//end of else
              }//end of onClick method    
              });//end of OnclickListener method
        }//end of onCreate method
      public void openGaleryVideo()
      {
        Intent intent=new Intent();
        intent.setType("video/*");
        intent.setAction(Intent.ACTION_GET_CONTENT);
        startActivityForResult(Intent.createChooser(intent, "Select Video"),SELECT_VIDEO);
      }//end of openGaleryVideo method
    
      public String getPath(Uri uri)
      {   
        String[] projection = { MediaStore.Video.Media.DATA};
        Cursor cursor = managedQuery(uri, projection, null, null, null);
        int column_index = cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATA);
        cursor.moveToFirst();
        return cursor.getString(column_index);
      }//end of getPath method
    
      //Response Class
      public class Response
      {
        int Id;
        String Name;
        String Type;
        String Value;
        String DefaultValue;
        int Flag;
        int Index;
      }//end of Response class
    
      //onActivityResult
      @SuppressWarnings("unused")
        public void onActivityResult(int requestCode, int resultCode, Intent data) 
        {
          super.onActivityResult(requestCode, resultCode, data);
          if (resultCode == RESULT_OK)
          {
            if (requestCode == SELECT_VIDEO) 
            {
              Uri videoUri = data.getData();
              path=getPath(videoUri);
              ScrollView scroll = new ScrollView(this);
              LinearLayout layout=new LinearLayout(this);
              layout.setOrientation(LinearLayout.VERTICAL);
              layout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); 
              scroll.addView(layout,new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
              setContentView(scroll);             
              SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME1);
              SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
              envelope.dotNet = true;
              //İsteğimizi zarf'a koyuyoruz
              envelope.setOutputSoapObject(request);
              HttpTransportSE transport = new HttpTransportSE(SERVICEURL);
              final  AlertDialog adr=new AlertDialog.Builder(this).create();
              Object response1=null;
              try
              {
                transport.call("http://tempuri.org/"+METHOD_NAME1, envelope);
                //getting the response from the webservice
                response1 =envelope.getResponse();
                JSONArray jArray= new JSONArray(response1.toString());
                for(int i=0;i<jArray.length();i++)
                {
                  JSONObject json_data= jArray.getJSONObject(i);
                  Response result= new Response();
                  result.Id= json_data.getInt("Id");
                  result.Name= json_data.getString("Name");
                  result.Type= json_data.getString("Type");
                  result.Value=json_data.getString("Value");
                  result.DefaultValue=json_data.getString("DefaultValue");
                  result.Flag=json_data.getInt("Flag");
                  result.Index=json_data.getInt("Index");
                  WebData.add(i,result);
                }//end of for loop     
              }//end of try 
              catch(Exception exception)
              {
                exception.printStackTrace();
              }//end of catch
    
              // BUBBLE create a list with the exact size of input fields
              this.dynaFields = new ArrayList<EditText>(WebData.size());
    
              for(int j=0;j<WebData.size();j++)
              {
                //BUBBLE: instantiate and add the current field to the list and view
                EditText newField = new EditText(this);
                this.dynaFields.add (newField)
                layout.addView(newField);
    
                TextView t= new TextView(this);
                t.setText(WebData.get(j).Name);
                layout.addView(t);
                if("Type"=="datetime")
                {
                  //BUBBLE
                  newField.setId(j);
                  SimpleDateFormat sdf = new SimpleDateFormat( "yyyy/MM/dd" ); 
                  newField.setText(sdf.format( new Date()));
    
                }//end of if
    
              }//end of for loop
              Button button= new Button(this);
              button.setClickable(true);
              button.setText("Yükle");
              layout.addView(button);
              button.setOnClickListener(new View.OnClickListener() {
    
                  @Override
                  public void onClick(View arg0)
                  {
                  // TODO Auto-generated method stub
    
                  }
                  });
            }//end of If request code
          }//end of If result code
        }//end of onActivityResult
    }//end of main
    

    In a nutshell, I’ve created an ArrayList of EditText

    private List<EditText> dynaFields = null;
    

    Then the list have been instantiated right before the fields creation:

    // BUBBLE create a list with the exact size of input fields
    this.dynaFields = new ArrayList<EditText>(WebData.size());
    

    And finally, once the fields were created, I’ve added them to both the list and the view:

    // instantiate and add the current field to the list and view
    EditText newField = new EditText(this);
    this.dynaFields.add (newField)
    layout.addView(newField);
    

    I’ve made some small simplifications in your if statements, so I could use just one EditText object.

    To get the components, just iterate through the array in the onClick method:

    public void onClick(View arg0)
    {
        TextField currText;
        for (currText : UploaderActivity.this.dynaFields) {
         // TODO: get the current EditText text and have fun!
        }    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a class which will let me get requested data from
When trying to get some data on my android client from my webservice (running
Im trying to get a response from a function in a webservice but i
I'm trying to get data from a webservice, returning just one result, the number
So I'm trying to get data from my sql database and sort it by
I am trying to get data from my interface, written in c, to another
I am trying to get my data from a query string, but use it
I'm trying to get some data from a certain web-based api using the libcurl
I'm trying to get character data from www.wowarmory.com using PHP and cURL. The code
I am trying to get data back from a PHP file assigned with GET

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.