我正在使用下面的代码发送一个http POST请求,该请求将对象发送到WCF服务.这工作正常,但如果我的WCF服务还需要其他参数会发生什么?如何从我的Android客户端发送它们?
这是我到目前为止编写的代码:
StringBuilder sb = new StringBuilder();
String http = "http://android.schoolportal.gr/Service.svc/SaveValues";
HttpURLConnection urlConnection=null;
try {
URL url = new URL(http);
urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setDoOutput(true);
urlConnection.setRequestMethod("POST");
urlConnection.setUseCaches(false);
urlConnection.setConnectTimeout(10000);
urlConnection.setReadTimeout(10000);
urlConnection.setRequestProperty("Content-Type","application/json");
urlConnection.setRequestProperty("Host", "android.schoolportal.gr");
urlConnection.connect();
//Create JSONObject here
JSONObject jsonParam = new JSONObject();
jsonParam.put("ID", "25");
jsonParam.put("description", "Real");
jsonParam.put("enable", "true");
OutputStreamWriter out = new OutputStreamWriter(urlConnection.getOutputStream());
out.write(jsonParam.toString());
out.close();
int HttpResult =urlConnection.getResponseCode();
if(HttpResult ==HttpURLConnection.HTTP_OK){
BufferedReader br = new BufferedReader(new InputStreamReader(
urlConnection.getInputStream(),"utf-8"));
String line = null;
while ((line = br.readLine()) != null) {
sb.append(line + …
Run Code Online (Sandbox Code Playgroud) 我已经写了一个DialogFragment.现在我意识到我希望它像AlertDialog一样有一个正面和负面的按钮.如何在保持我编写的代码的同时实现这样的目标?
public class DoublePlayerChooser extends DialogFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setStyle(DialogFragment.STYLE_NORMAL,0);
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new AlertDialog.Builder(getActivity())
.setTitle("title")
.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// do something...
}
}
)
.setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
dialog.dismiss();
}
}
)
.create();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.doubleplayerchooser, container, false);
getDialog().setTitle("Enter Players");
firstPlayerPicker = …
Run Code Online (Sandbox Code Playgroud) 我在android中构建我的第一个应用程序.我做了一个dialogFragment,但它看起来不够好.因为我有一个风格和主题,我用它setStyle(DialogFragment.STYLE_NORMAL,0)
.我想要的是片段的边缘像框架一样是黑色的,或者它的角是圆的.我想我必须在xml中编写自己的风格并将其放入样式中,但我不确定.有人能指出我正确的方向吗?感谢您的时间.
打开Eclipse时遇到问题.在错误日志中它说:
unable to find action set org.eclipse.wb.core.ui.actionset
org.eclipse.rse.core.search.searchActionSet
org.eclipse.rse.core.search.searchActionSet
org.eclipse.mylyn.doc.actionSet
org.eclipse.mylyn.context.ui.actionSet
Run Code Online (Sandbox Code Playgroud)
我正在使用Eclipse juno(版本4.2),我的ADT是版本20和Java 1.6你知道我应该做什么吗?
您好,我正在构建一个 wcf 服务,我试图让它以 StreamedResponse 的形式发送请求。现在我的服务用于返回对象列表,现在应该只返回一个流。我的问题是如何转换此列表的对象作为流,以便可以正确发送。我正在用 C# 编写我的 wcf 服务。谢谢您的时间
嗨,大家好我正在开发一个Android应用程序.我正在使用alertDialog类.我有自定义列表视图和2个按钮.在我的自定义列表视图中,我有一个EditText字段.但是当对话框弹出时我触摸EditText而光标在文本框中开始闪烁,软键盘没有出现.是不是因为alertdialog?感谢您的时间.
public class ProgressReport extends ListActivity {
private ResultSet receivedData;
private StudentProgressAdapter ca;
private Button btnRtn;
ArrayList<String> content =new ArrayList<String>();
ArrayList<String> subContent = new ArrayList<String>();
AlertDialog dialog ;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTheme(android.R.style.Theme_Holo_Light);
setContentView(R.layout.examslayout);
for(int i =0;i<20;i++)
content.add("ELEMENTARY: "+i);
for(int i =0;i<20;i++)
subContent.add("?????? ?????????");
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Student Stats").setPositiveButton("Yes",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
// if this button is clicked, close
// current activity
//MainActivity.this.finish();
}
})
.setNegativeButton("No",new DialogInterface.OnClickListener() {
public void …
Run Code Online (Sandbox Code Playgroud) 我想从我的android应用程序中显示全景图,该全景图是在线的,并且我将其网址加载到了webview上,但无法正常工作。它只是它的一部分,不会旋转或上下颠倒。我不知道从哪里开始,您能指出我正确的方向吗?先感谢您
在我的android应用程序中,我有一个大型的ArrayList对象(超过100个),并且我使用putExtra(key,value)函数通过意图将此ArrayList从activity传递给activity.当我做这样的事情时,内存明智地发生了什么,ArrayList是否被复制,所以它现在占用了它所需的内存的两倍?或者jst被引用,所以空间保持不变?
我想通过intent从一个Activity转移到另一个ArrayList.我怎么能这样做,因为我无法实现JSONObject类parcelable