gpt4 book ai didi

java - 如何在弹出窗口中设置textview?

转载 作者:行者123 更新时间:2023-12-01 15:08:36 24 4
gpt4 key购买 nike

我正在尝试在弹出窗口中设置 TextView ,并且进入 TextView 弹出窗口的字符串来自 SOAP Web 服务调用。我在 logCat 和 PopUp 弹出窗口中看到字符串消息,但由于某种原因,我无法设置 TextView 来显示我的消息。我缺少什么。

谢谢你。

    public void wtfPopUp()
{

//

String PopYesNo;
String PopMsgAll = null;
//
////////////////////////FIRST CALL FOR YES-NO POP Status BEGIN
SoapObject Request = new SoapObject(NAMESPACEPopYesNo, METHOD_NAMEPopYesNo);

SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
soapEnvelope.dotNet = true;
soapEnvelope.setOutputSoapObject(Request);
HttpTransportSE ahtt = new HttpTransportSE(URLPopYesNo);

//////////////////////// SECOND CALL FOR POP MESSAGE BEGIN

SoapObject Request2 = new SoapObject(NAMESPACEAllPop, METHOD_NAMEAllPop);
// Request.addProperty("c_idid", "1");
SoapSerializationEnvelope soapEnvelope2 = new SoapSerializationEnvelope(SoapEnvelope.VER11);
soapEnvelope2.dotNet = true;
soapEnvelope2.setOutputSoapObject(Request2);
HttpTransportSE ahtt2 = new HttpTransportSE(URLAllPop);

//////////////////////// SECOND CALL FOR MESSAGE END

try
{
Log.d("myAppWtf", "at getPopUpAllTRY");
ahtt.call(SOAP_ACTIONPopYesNo, soapEnvelope);
SoapObject oResponse = (SoapObject)soapEnvelope.bodyIn;
PopYesNo = oResponse.getPropertyAsString(0).toString();
Log.d("myAppYesNo", oResponse.getPropertyAsString(0).toString());


if(PopYesNo.equals("PopUp_ON") )
{


try{

//////////////////////// SECOND CALL FOR MESSAGE BEGIN

ahtt2.call(SOAP_ACTIONAllPop, soapEnvelope2);
SoapObject oResponse2 = (SoapObject)soapEnvelope2.bodyIn;
PopMsgAll = oResponse2.getPropertyAsString(0).toString();
Log.d("myAppMSGGGG", oResponse2.getPropertyAsString(0).toString());

///////////////////////////// SECOND CALL FOR MESSAGE END

}
catch(Exception ms){

ms.printStackTrace();

}



// POP UP CODE
LayoutInflater li = LayoutInflater.from(context);
View promptsView = li.inflate(R.layout.popup_all, null);

AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);

// set prompts.xml to alertdialog builder
alertDialogBuilder.setView(promptsView);



// set dialog message
alertDialogBuilder
.setCancelable(false)
.setNegativeButton("Cool",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
dialog.cancel();
}
});

// create alert dialog
AlertDialog alertDialog = alertDialogBuilder.create();




// show it
alertDialog.show();


// TEXT FOR POP UP MSG
txtViewPop = (TextView)findViewById(R.id.txtMsgAll);
txtViewPop.setText(PopMsgAll.toString());
// txtViewPop.setTextColor(Color.rgb(2, 39, 72));



}


}

catch(Exception ix)
{
ix.printStackTrace();
}




}

最佳答案

用这个

txtViewPop =(TextView) promptsView.findViewById(R.id.txtMsgAll);
^^^^^^^^^^^^

而不是

txtViewPop = (TextView)findViewById(R.id.txtMsgAll);

关于java - 如何在弹出窗口中设置textview?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12626410/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com