有一个相关的问题,但我无法清楚地得到答案.
我想POST一个简短的xml代码
<aaaLogin inName="admin" inPassword="admin123"/>
Run Code Online (Sandbox Code Playgroud)
通过HTTP到特定的URL地址.Web服务将向我发回XML代码.重要的是我将解析收到的XML,并希望将其存储为文件.
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://192.168.192.131/"); //URL address
StringEntity se = new StringEntity("<aaaLogin inName=\"admin\" inPassword=\"admin123\"/>",HTTP.UTF_8); //XML as a string
se.setContentType("text/xml"); //declare it as XML
httppost.setHeader("Content-Type","application/soap+xml;charset=UTF-8");
httppost.setEntity(se);
BasicHttpResponse httpResponse = (BasicHttpResponse) httpclient .execute(httppost);
tvData.setText(httpResponse.getStatusLine().toString()); //text view is expected to print the response
Run Code Online (Sandbox Code Playgroud)
收到回复有问题.此外,我没有写任何东西来保存收到的XML作为文件.有人可以编写代码片段吗?
我试图在一个XML解析非UI线程的ListView中显示的SimpleCursorAdapter上调用.notifyDataSetChange(),并且不能在我的生活中弄清楚如何.我已经搜遍了所有我发现的文章都是关于从ListView本身内部进行刷新的文章,我不会这样做.我无法想出一种方法来传递适配器或从父节点获取它或我需要做什么来从另一个线程调用它的方法.
ListView将在下次启动活动时更新,但是我希望它在XML解析完成后立即刷新,以便用户立即看到新数据.
答案可能很简单; 它只是在逃避我.在此先感谢您的帮助!
这是我的代码:
public class DirectoryListActivity extends DirectoryActivity {
public final Handler mHandler = new Handler();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.directory_list);
// Populate the ListView
SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
queryBuilder.setTables(
directoryPeople.PEOPLE_TABLE
);
String asColumnsToReturn[] = {
//snip
};
mCursor = queryBuilder.query(mDB, asColumnsToReturn, null, null,
null, null, directoryPeople.DEFAULT_SORT_ORDER);
startManagingCursor(mCursor);
// HERE'S THE ADAPTER
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
R.layout.directory_people_item, mCursor,
new String[]{
//snip
new int[]{
//snip
);
ListView av = (ListView)findViewById(R.id.listPeople);
av.setAdapter(adapter);
//Perform sync in …Run Code Online (Sandbox Code Playgroud) 我需要登录我们的应用程序,并希望尽可能少地记录由于记录所消耗的时间.我正在考虑使用MSMQ,以便应用程序将登录到MSMQ,然后我可以异步地将消息从MSMQ记录到数据库/文件.
这个想法在性能方面是否合适?或使用log4net同步记录到平面文件更好.
此外,我正在考虑编写日志记录抽象层,以便以后插入任何日志记录工具而不影响其他代码.
请指教.
谢谢,sveerap
可能重复:
Objective-C教程
我正在制作iPhone应用程序,但我不知道如何使用这个if-else条件.有人可以解释它是如何工作的吗?
我试图从二维字符串数组创建一个表.但是,我厌倦了在代码中创建视图,因此出于某种原因,我的图像永远不可见,我的文本视图不会分成多行,而是会删除文本.
另外,我在我的代码中的每个textview上都放了id,当有人点击textview时,我希望我可以使用该ID来识别点击的行.不幸的是,事实并非如此.
有没有什么好方法可以识别正确的排?
问候
for (int current=0; current<cityArr.length; current++) {
TableRow tr = new TableRow(this);
tr.setId(100+current);
tr.setLayoutParams(new LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
TextView labelTV = new TextView(this);
labelTV.setId(current);
labelTV.setText(cityArr[current][0]);
labelTV.setTextColor(Color.BLACK);
labelTV.setLayoutParams(new LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
tr.addView(labelTV);
ImageView mapView = new ImageView(this);
mapView.setImageResource(R.drawable.list_icon_map);
mapView.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT, 5));
tr.addView(mapView);
tlcity.addView(tr, new TableLayout.LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
}
Run Code Online (Sandbox Code Playgroud) 我的课程如下
namespace Coverage {
public class ClassInfo {
public string ClassName;
public int BlocksCovered;
public int BlocksNotCovered;
public ClassInfo() {}
public ClassInfo(string ClassName, int BlocksCovered, int BlocksNotCovered)
{
this.ClassName = ClassName;
this.BlocksCovered = BlocksCovered;
this.BlocksNotCovered = BlocksNotCovered;
}
}
public class Module {
public List<ClassInfo> ClassInfoList;
public int BlocksCovered;
public int BlocksNotCovered;
public string moduleName;
public Module()
{
ClassInfoList = new List<ClassInfo>();
BlocksCovered = 0;
BlocksNotCovered = 0;
moduleName = "";
}
Run Code Online (Sandbox Code Playgroud)
使用以下序列化程序代码
XmlSerializer SerializerObj = new XmlSerializer(typeof(Module));
// Create …Run Code Online (Sandbox Code Playgroud) 这是我的代码:
package com.example.userpage;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class UserPage extends Activity {
String tv,tv1;
EditText name,pass;
TextView x,y;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button button = (Button) findViewById(R.id.widget44);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
name.setText(" ");
pass.setText(" ");
}
});
x = (TextView) findViewById(R.id.widget46);
y = (TextView) findViewById(R.id.widget47);
name = (EditText)findViewById(R.id.widget41);
pass = (EditText)findViewById(R.id.widget42);
Button …Run Code Online (Sandbox Code Playgroud) 所以也许这是一个愚蠢的问题,我在想这个,但我有以下情况.我正在制作一个"类Shell",它可以运行抽象的"类Action"对象.它是唯一应该创建或使用这些对象的类.操作对象需要访问Shell以对其执行特定操作,但我试图避免为此添加公共接口(不应该允许其他人这样做).
我原来有一个简单的(不那么优雅)
class Shell
{
public:
bool checkThing();
// etc...
private:
bool _thing;
};
class Action
{
public:
virtual void execute( Shell &s )=0;
};
class ChangeAction : public Action
{
public:
void execute( Shell &s )
{
// requires friendship or public mutator!
s._thing = true;
}
};
Run Code Online (Sandbox Code Playgroud)
所以我考虑了一个嵌套类Action,但是我想把它变成私有的(为什么让其他人做除了Shell之外的具体动作,对吧?)
class Shell
{
public:
bool checkThing();
// etc...
private:
bool _thing;
class Action;
};
class Shell::Action
{
public:
virtual void execute( Shell &s )=0;
};
class ChangeAction : public Shell::Action …Run Code Online (Sandbox Code Playgroud) 我有两个表A和B.我可以触发Linq查询并获取各个表所需的数据.我知道每个表将返回的内容如示例所示.但是,当我加入两个表时我都不知道Linq查询的返回类型.这个问题可以通过创建一个将在其中包含ID,Name和Address属性的类来解决.但是,每次在根据返回类型编写连接查询之前,我将不得不创建一个不方便的类的方法是否有任何其他方法可用于实现此目的
private IList<A> GetA()
{
var query = from a in objA
select a;
return query.ToList();
}
private IList<B> GetB()
{
var query = from b in objB
select b;
return query.ToList();
}
private IList<**returnType**?> GetJoinAAndB()
{
var query = from a in objA
join b in objB
on a.ID equals b.AID
select new { a.ID, a.Name, b.Address };
return query.ToList();
}
Run Code Online (Sandbox Code Playgroud) android ×4
c# ×3
.net ×2
xml ×2
c ×1
c++ ×1
friend ×1
http ×1
http-post ×1
inheritance ×1
iphone ×1
layoutparams ×1
linq ×1
logging ×1
nested-class ×1
tablelayout ×1
tablerow ×1
winforms ×1