小编Fah*_*que的帖子

带有String的GSON问题

    String s = "m\\"+"/m\\/m/m/m/m/m";

    LinkedHashMap<String, String> hm = new LinkedHashMap<>();

    hm.put("test", s);

    System.out.println(hm+"  Hash map = "+hm.toString());
Run Code Online (Sandbox Code Playgroud)

精细输出是 {test=m\/m\/m/m/m/m/m} Hash map = {test=m\/m\/m/m/m/m/m}

    String s2 = new Gson().toJson(hm.toString());

    System.out.println("Json result is "+s2);
Run Code Online (Sandbox Code Playgroud)

输出不好Json result is "{test\u003dm\\/m\\/m/m/m/m/m}"

GSON要疯了还是我做错了什么吗?反斜杠发生了什么,从哪里u003d出现?我知道很久以前就存在这种性质的错误,但它已经解决了.我该如何解决这个问题?提前致谢.

java linkedhashmap gson

32
推荐指数
1
解决办法
3万
查看次数

初学Android开发:findViewById问题

运行我的基本应用程序时收到以下错误消息.该应用程序包含一个名为button1的按钮和一个名为topLeft的textView.

07-01 15:33:02.754: D/AndroidRuntime(2334): Shutting down VM 07-01 15:33:02.754: W/dalvikvm(2334): threadid=1: thread exiting with
uncaught exception (group=0x40a13300) 07-01 15:33:02.984:
E/AndroidRuntime(2334): FATAL EXCEPTION: main 07-01 15:33:02.984:
E/AndroidRuntime(2334): java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.example.myfirstapp/com.example.myfirstapp.MainActivity}:
java.lang.NullPointerException 07-01 15:33:02.984:
E/AndroidRuntime(2334): at  android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983)
07-01 15:33:02.984: E/AndroidRuntime(2334): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
07-01 15:33:02.984: E/AndroidRuntime(2334): at android.app.ActivityThread.access$600(ActivityThread.java:130) 07-01
15:33:02.984: E/AndroidRuntime(2334): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
07-01 15:33:02.984: E/AndroidRuntime(2334): at android.os.Handler.dispatchMessage(Handler.java:99) 07-01
15:33:02.984: E/AndroidRuntime(2334): at android.os.Looper.loop(Looper.java:137) 07-01 15:33:02.984:
E/AndroidRuntime(2334): at android.app.ActivityThread.main(ActivityThread.java:4745) 07-01
15:33:02.984: E/AndroidRuntime(2334): at java.lang.reflect.Method.invokeNative(Native Method) 07-01
15:33:02.984: E/AndroidRuntime(2334): at java.lang.reflect.Method.invoke(Method.java:511) 07-01 …
Run Code Online (Sandbox Code Playgroud)

android android-layout

6
推荐指数
1
解决办法
2万
查看次数

AsyncHttpClient身份验证失败

我试图通过网站进行身份验证.我在用AsyncHttpClient.下面是我正在尝试的代码.

这是我的代码,

public class LoginActivity extends Activity {

    String tag = "LoginActivity";
    Button requestBtn;
    AsyncHttpClient httpClient = new AsyncHttpClient();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);

        requestBtn = (Button) findViewById(R.id.upload_file);

        PersistentCookieStore myCookieStore = new PersistentCookieStore(this);
        httpClient.setCookieStore(myCookieStore);

        httpClient.setBasicAuth(ApplicationConstants.userName,
                ApplicationConstants.password, new AuthScope(
                        "http://*.*.*.*:8080/someUrl", 8080,
                        AuthScope.ANY_REALM));




        requestBtn.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
      httpClient.get("http://*.*.*.*:8080/someurl",new AsyncHttpResponseHandler() {

                @Override
                public void onSuccess(String response) {
                System.out.println(response);
                Log.d("Sucessful upload","Onsucess" + response);
                }

                @Override
                public void onFailure(Throwable arg0,String arg1) {

                Log.d("LoginActivity",arg0.toString());
                arg0.printStackTrace();
                super.onFailure(arg0, …
Run Code Online (Sandbox Code Playgroud)

authentication android android-async-http

2
推荐指数
2
解决办法
7143
查看次数

具有子视图的自定义布局

我对此有误。无法弄清楚如何在我的自定义视图(相对布局)中使用子视图。

   <RelativeLayout >   

    <com.xxxxxx.FavouriteImageView
        android:id="@+id/favorite_status"
        android:layout_width="25dp"
        android:layout_height="25dp"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:layout_marginRight="15dp"
        android:clickable="true" >

        <ImageView
            android:id="@+id/favourite_iv"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@drawable/yellow_star"
            android:clickable="false" />

        <ProgressBar
            android:id="@+id/favorite_spinner"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:visibility="gone"
            android:clickable="false" />

    </com.xxxxxxxx.FavouriteImageView>
Run Code Online (Sandbox Code Playgroud)

public class FavouriteImageView extends RelativeLayout{

ImageView star;
ProgressBar spinner;
boolean isFavorite;

Context context;

public FavouriteImageView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    this.context= context;
    findChildViews();}

public FavouriteImageView(Context context, AttributeSet attrs) {
    super(context, attrs);
    this.context= context;
    findChildViews();
}

public FavouriteImageView(Context context) {
    super(context);
    this.context= context;
    findChildViews();}


private void findChildViews(){

    star = (ImageView) …
Run Code Online (Sandbox Code Playgroud)

android android-custom-view

2
推荐指数
1
解决办法
1004
查看次数