Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/216.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在android的文本视图中放置soap url值_Android_Split_Substring - Fatal编程技术网

如何在android的文本视图中放置soap url值

如何在android的文本视图中放置soap url值,android,split,substring,Android,Split,Substring,如何在android的textview中放置soap url值,我想以特定的顺序显示数据,我将数据一个一个地拆分,但现在我想将数据放置在特定的textview、Edittext中,我该如何做请您帮助…提前感谢 public class MainActivity extends Activity { private static final String SOAP_ACTION = "http://tempuri.org/Sessionamount";

如何在android的textview中放置soap url值,我想以特定的顺序显示数据,我将数据一个一个地拆分,但现在我想将数据放置在特定的textview、Edittext中,我该如何做请您帮助…提前感谢

    public class MainActivity extends Activity {

        private static final String SOAP_ACTION = "http://tempuri.org/Sessionamount";

        private static final String OPERATION_NAME = "Sessionamount";

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

       private static final String SOAP_ADDRESS = "220.226.170.5/service.asmx?WSDL";

        TextView tvData1,ts;
        EditText edata;
        ImageView button;
        String Date;
        HttpTransportSE httpTransport;
        SoapSerializationEnvelope envelope;
        Object response;
        //SoapPrimitive s;
        ProgressDialog progress;
   // 
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);

            progress = new ProgressDialog(MainActivity.this);
            button = (ImageView) findViewById(R.id.imageView1);
            tvData1 = (TextView) findViewById(R.id.textView3);
            ts = (TextView) findViewById(R.id.textView1);
            edata = (EditText) findViewById(R.id.editText1);



        // calendar function    


            final Calendar myCalendar = Calendar.getInstance();
            final DatePickerDialog.OnDateSetListener date = new DatePickerDialog.OnDateSetListener() {

                @Override
                public void onDateSet(DatePicker view, int year, int monthOfYear,
                        int dayOfMonth) {
                    // TODO Auto-generated method stub
                    myCalendar.set(Calendar.YEAR, year);
                    myCalendar.set(Calendar.MONTH, monthOfYear);
                    myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
                    updateLabel();
                }

                private void updateLabel() {
                    // TODO Auto-generated method stub

                    String myFormat = "dd/MM/yyyy";
                    SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.US);
                    edata.setText(sdf.format(myCalendar.getTime()));


                }

            };

    // listener for button

           edata.setOnClickListener(new OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        // TODO Auto-generated method stub
                      envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
                    envelope.dotNet = true;
                    envelope.setOutputSoapObject(request);*/

                    envelope=new SoapSerializationEnvelope(SoapEnvelope.VER11);
                    envelope.dotNet=true;
                    envelope.setOutputSoapObject(request);

                    httpTransport = new HttpTransportSE(SOAP_ADDRESS);

                    try {

                         serviceCall();

                    } catch (Exception exception) {

                        tvData1.setText(exception.toString()
                            + " Or No Records Found!");

                    }

                }
            });

                }


        void serviceCall() {

            progress.setMessage("Loading Contents");
            progress.show();

            progress.setMessage("Redirecting credientials");
            progress.show();

                new AsyncTask<Void, Void, Void>() {
                    @Override
                protected Void doInBackground(Void... params) {
                    try {

                        httpTransport.call(SOAP_ACTION, envelope);
                        response = envelope.getResponse();

                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        Toast.makeText(getApplicationContext(), e.getMessage(), 1)
                                .show();
                        e.printStackTrace();
                    } catch (XmlPullParserException e) {
                        // TODO Auto-generated catch block
                        Toast.makeText(getApplicationContext(), e.getMessage(), 1)
                                .show();
                        e.printStackTrace();
                    }

                    return null;
                }


                @Override

        protected void onPostExecute(Void result) {
            String str = "";

            if (progress != null)
                progress.dismiss();
            if (response !=null)
            {
        /* private static List <String> parse (String str)
                {
                    String temp; 
                List <String> list = new ArrayList <String> (); 
                if (str!= null    && Str.length ()> 0) 
                {
                int start = str.indexOf ("string"); 
                int end = str.lastIndexOf (";"); 
                temp = str.substring (start, end - 3); 
                String [] test = temp.split (";"); 
                for (int i = 0; i <test.length; i++)
                {
                    if (i == 0) {temp = test [i]. substring (7);
                    } 
                    else 
                    {
                    temp = test [i]. substring (8);
                    } 
                    int index = temp.indexOf (","); 
                    list.add (temp.substring (0, index));
                    }}
                return list;
                } */
                String resultArr[] = response.toString().split(";");

                /*for(int i=0;i<resultArr.length;i++)
                {
                    str=str+resultArr[i]+"\n\n";
                    tvData1.setText(str);

                }*/

                for(int i=0;i<resultArr.length;i++)
                {
                    str=str+resultArr[i]+"\n\n";
                    //tvData1.setText(str);
                    edata.setText(str);
                    tvData1.setText(str);
            }

            } else
                //tvData1.setText("");
                Toast.makeText(getApplicationContext(), "No Records Found", 1)
                        .show();
            }   

    }.execute();


        }   
    }




    //this is my xml

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

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >

            <EditText
                android:id="@+id/editText1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:hint="DD/MM/YY"
                android:textColor="#FFFFFF"
                android:layout_weight="1"
                android:ems="10" >

                <requestFocus />
            </EditText>

            <ImageView
                android:id="@+id/imageView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="20dp"
                android:layout_weight="1"
                android:src="@drawable/search" />

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"

             android:layout_marginTop="30dp"

            android:orientation="horizontal" >

            <TextView
                android:id="@+id/textView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                  android:background="@drawable/roundborder"
                android:text="Session                         Amount"
                android:textColor="#FFFFFF"
                android:textSize="20sp"
                android:textStyle="bold"
                android:visibility="invisible" />

        <!--     <TextView
                android:id="@+id/textView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="Amount"
                  android:background="@drawable/roundborder"
                android:textColor="#FFFFFF"
                android:visibility="invisible"
                android:textSize="20sp"
                android:textStyle="bold" /> -->

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
                                android:layout_marginTop="30dp"



            android:layout_height="wrap_content"
            android:orientation="horizontal" >

            <TextView
                android:id="@+id/textView3"
                android:layout_width="wrap_content"
                android:textColor="#FFFFFF"



      android:background="@drawable/roundborder"
            android:visibility="invisible"
            android:layout_weight="2"
            android:layout_height="match_parent"
            android:text="" />

    </LinearLayout>

    </LinearLayout>



//this is the format i need
​session                     Amount
Afternoon                   68788798
Morning                       87686978
Evening                       24232

I want to get the total amount of those amounts,I just add(+)  amount alone
How can i add​
Is there any concept

//The URL look like this,

​Afternoon-99127.79;Night-67236.27;Morning-61876.65;Evening-20271.42;Housekeeping-5444.05;
公共类MainActivity扩展活动{
私有静态最终字符串SOAP_ACTION=”http://tempuri.org/Sessionamount";
私有静态最终字符串操作\u NAME=“Sessionamount”;
私有静态最终字符串WSDL\u TARGET\u NAMESPACE=”http://tempuri.org/";
私有静态最终字符串SOAP_ADDRESS=“220.226.170.5/service.asmx?WSDL”;
文本视图tvData1,ts;
EditText-edata;
图像查看按钮;
字符串日期;
httpTransport-httpTransport;
信封;
目标反应;
//肥皂;
进程对话进程;
// 
@凌驾
创建时的公共void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
进度=新建进度对话框(MainActivity.this);
按钮=(ImageView)findViewById(R.id.imageView1);
tvData1=(TextView)findViewById(R.id.textView3);
ts=(TextView)findViewById(R.id.textView1);
edata=(EditText)findViewById(R.id.editText1);
//日历功能
最终日历myCalendar=Calendar.getInstance();
final DatePickerDialog.OnDateSetListener日期=新建DatePickerDialog.OnDateSetListener(){
@凌驾
公共无效onDateSet(日期选择器视图,整数年,整数月,
整数(每月的第几天){
//TODO自动生成的方法存根
myCalendar.set(Calendar.YEAR,YEAR);
myCalendar.set(Calendar.MONTH,monthOfYear);
myCalendar.set(Calendar.DAY\u OF\u MONTH,dayOfMonth);
updateLabel();
}
私有void updateLabel(){
//TODO自动生成的方法存根
字符串myFormat=“dd/MM/yyyy”;
SimpleDataFormat sdf=新的SimpleDataFormat(myFormat,Locale.US);
setText(sdf.format(myCalendar.getTime());
}
};
//按钮的侦听器
setOnClickListener(新的OnClickListener(){
@凌驾
公共void onClick(视图v){
//TODO自动生成的方法存根
信封=新的SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.setOutputSoapObject(请求)*/
信封=新的SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.setOutputSoapObject(请求);
httpTransport=新的HttpTransportSE(SOAP\U地址);
试一试{
serviceCall();
}捕获(异常){
tvData1.setText(exception.toString()异常)
+“或者找不到任何记录!”);
}
}
});
}
void serviceCall(){
progress.setMessage(“加载内容”);
progress.show();
progress.setMessage(“重定向凭证”);
progress.show();
新建异步任务(){
@凌驾
受保护的Void doInBackground(Void…参数){
试一试{
调用(SOAP_操作,信封);
response=envelope.getResponse();
}捕获(IOE异常){
//TODO自动生成的捕捉块
Toast.makeText(getApplicationContext(),e.getMessage(),1)
.show();
e、 printStackTrace();
}catch(XMLPullParseRexE){
//TODO自动生成的捕捉块
Toast.makeText(getApplicationContext(),e.getMessage(),1)
.show();
e、 printStackTrace();
}
返回null;
}
@凌驾
受保护的void onPostExecute(void结果){
字符串str=“”;
如果(进度!=null)
进步。解散();
if(响应!=null)
{
/*私有静态列表解析(字符串str)
{
字符串温度;
List=newarraylist();
如果(str!=null&&str.length()>0)
{
int start=str.indexOf(“字符串”);
int end=str.lastIndexOf(“;”);
温度=str.substring(开始,结束-3);
字符串[]测试=临时拆分(“;”);
对于(int i=0;i,如果您喜欢下面的内容

          for(int i=0;i<resultArr.length;i++)
          {
                str=str+resultArr[i]+"\n\n";
                //tvData1.setText(str);
                edata.setText(str);
                tvData1.setText(str);
           }

直接…通过您的textview.settext方法…有什么问题吗..发布
resultar
的内容和长度内容在我的帖子的最后一行谢谢!我还有一个疑问如何拆分字符串,例如在我的链接中,我想在“-”之间拆分,是否有任何可能如果我的上述答案对你有帮助,请先投票并打勾。这对其他人会有帮助。如果你有任何其他问题,请在不同的线程中提问并将链接发送给我。很高兴帮助你。如果你想在“-”处拆分,那么
String[]array=str.split(“-”);
@Aniruddha这是我的新线程…@user3736314我已经回答了这个问题,请接受它(打勾)
                tvData1.setText(resultArr[0]);
                edata.setText(resultArr[1]);      // this is the general idea. You can do this only if you know the exact position of the value and length of the array.
                tvData1.setText(resultArr[2]);