小编Zaf*_*glu的帖子

如何在嵌套的JSON结果中解析动态JSON密钥?

我有以下格式的JSON结果,JSON Lint将其显示为"有效响应".

我的问题是:如何访问"question_mark"的内容,因为"141","8911"等都是动态值?

我的示例代码用于访问"product"的值.

//Consider I have the first <code>JSONObject</code> of the "search_result" array and 
//I access it's "product" value as below.
String product = jsonObject.optString("product"); //where jsonObject is of type JSONObject.
//<code>product<code> now contains "abc".
Run Code Online (Sandbox Code Playgroud)

JSON:

{
 "status": "OK",
 "search_result": [

            {
                "product": "abc",
                "id": "1132",
                "question_mark": {
                    "141": {
                        "count": "141",
                        "more_description": "this is abc",
                        "seq": "2"
                    },
                    "8911": {
                        "count": "8911",
                        "more_desc": "this is cup",
                        "seq": "1"
                    }
                },
                "name": "some name",
                "description": "This is …
Run Code Online (Sandbox Code Playgroud)

java android json

51
推荐指数
2
解决办法
7万
查看次数

Picasso IllegalArgumentException目标不能为null

我正在尝试通过在我的项目中使用Picasso库来设置图像.

当我点击View的图像时,我在Picasso执行时遇到错误.

该应用程序的Logcat

  java.lang.IllegalArgumentException: Target must not be null.
            at com.squareup.picasso.RequestCreator.into(RequestCreator.java:340)
            at com.squareup.picasso.RequestCreator.into(RequestCreator.java:326)
            at com.zafer.celaloglu.FragmentsandActivities.UnfoldableDetailsFragment.openDetails(UnfoldableDetailsFragment.java:89)
            at com.zafer.celaloglu.model.PaintingsAdapter.onClick(PaintingsAdapter.java:52)
            at android.view.View.performClick(View.java:4084)
            at android.view.View$PerformClick.run(View.java:16966)
            at android.os.Handler.handleCallback(Handler.java:615)
            at android.os.Handler.dispatchMessage(Handler.java:92)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:4745)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
            at dalvik.system.NativeStart.main(Native Method)
Run Code Online (Sandbox Code Playgroud)

UnfoldableDetailsFragment 89 =

public void openDetails(View coverView, Painting painting) {
    ImageView image = (ImageView) coverView.findViewById(R.id.details_image);
    TextView title = (TextView) coverView.findViewById(R.id.details_title);
    TextView description = (TextView) coverView.findViewById(R.id.details_text);

    Picasso.with(getActivity()).load(painting.getImageId()).into(image); ->89. LINE
    Log.i("bilgi", "basildi");

    title.setText(painting.getTitle());

    SpannableBuilder builder = new SpannableBuilder(getActivity());
    builder
            .createStyle().setFont(Typeface.DEFAULT_BOLD).apply()
            .append(R.string.year).append(": …
Run Code Online (Sandbox Code Playgroud)

android picasso

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

如何根据设置的主题更改flutter中的状态栏图标和文本颜色?

如何在没有任何第三方插件的情况下更新状态栏图标的颜色?

在我的主题课程中,我有一个函数,我正在尝试下面的代码,但尚未实现结果:

目前的主题代码:


// custom light theme for app
  static final customLightTheme = ThemeData.light().copyWith(
    brightness: Brightness.light,
    primaryColor: notWhite,
    accentColor: Colors.amberAccent,
    scaffoldBackgroundColor: notWhite,
    primaryTextTheme: TextTheme(
      title: TextStyle(
        color: Colors.black
      ),

    ),
    appBarTheme: AppBarTheme(
      iconTheme: IconThemeData(color: Colors.black),
      elevation: 0.0,
    )
  );

  // custom dark theme for app
  static final customDarkTheme = ThemeData.dark().copyWith(
    brightness: Brightness.dark,
    primaryColor: Colors.black,
      accentColor: Colors.orange,
      scaffoldBackgroundColor: Colors.black87,
      primaryTextTheme: TextTheme(
        title: TextStyle(
            color: Colors.white
        ),

      ),
      appBarTheme: AppBarTheme(
        iconTheme: IconThemeData(color: Colors.white),
        elevation: 0.0,
      ),

  );

Run Code Online (Sandbox Code Playgroud)

主题更改代码:


// set theme for …
Run Code Online (Sandbox Code Playgroud)

user-interface android statusbar ios flutter

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

Android build fails with R8

Build is failing with the following error upon enabling R8 on android studio 3.4-RC3. Build is successful if android.enableR8=false

Undefined value encountered during compilation. This is typically caused by invalid dex input that uses a register that is not define on all control-flow paths leading to the use.

What is this undefined value and how do I fix this error?

> Task :app:transformClassesAndResourcesWithR8ForStageInternal FAILED
D8: Undefined value encountered during compilation. This is typically caused by invalid dex input that uses …
Run Code Online (Sandbox Code Playgroud)

android gradle android-studio gradle-kotlin-dsl android-r8

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

如何解决类型View中的"setOnKeyListener(View.OnKeyListener)不适用于android上的参数(new OnKeyListener(){})"错误?

我收到此错误的错误"类型View中的方法setOnKeyListener(View.OnKeyListener)不适用于参数(new OnKeyListener(){})"

我怎样才能克服这个问题?

protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_first_app);

    ListView myListView =(ListView)findViewById(R.id.myListView);

    final EditText myEditText =(EditText)findViewById(R.id.myEditText);

   final ArrayList<String> toDolist =new ArrayList<String>();

    final ArrayAdapter<String> aa;

    aa=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,toDolist);

    myListView.setAdapter(aa);

    myEditText.setOnKeyListener(new OnKeyListener() {

        public boolean onKey(View v, int keyCode, KeyEvent event) {

            if(event.getAction()==KeyEvent.ACTION_DOWN)

                if(keyCode==KeyEvent.KEYCODE_DPAD_CENTER){
                    toDolist.add(0,myEditText.getText().toString());

                    aa.notifyDataSetChanged();

                    myEditText.setText("");

                    return true;
                }
            return false;
        }
    });
Run Code Online (Sandbox Code Playgroud)

android

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

如何从 Fragment 切换到 Activity?

首先我想解释一下我的问题,

  1. Slide menu在我的应用程序中。我为此使用了 android.support.v4.app.Fragment
  2. 我可以轻松地从片段移动到活动。
  3. 我的问题是如何从片段移动到活动。

我尝试了以下代码但没有用。

FragmentManager fm = AddCaseFile.this.getSupportFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
HospitalizationDetails fragment=new HospitalizationDetails();
ft.replace(R.id.activity_main_content_fragment,fragment);
ft.addToBackStack(null);
ft.commit();
Run Code Online (Sandbox Code Playgroud)

AddCaseFile我目前的活动在哪里

HospitalizationDetails 是片段(我必须去)

提前致谢

android android-fragments

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

在 Picasso 库中,当我的图像被加载时,我现在如何触发哪个事件侦听器?

大家好,我在 android 项目中使用毕加索,现在我的问题是我需要在毕加索正在加载的图像上显示一些内容,这就是为什么我想知道我如何知道毕加索何时加载了图像,因为只有这样我才能在该图像上添加文本。此外,如果 picasso 不提供此功能,那么在 android 中使用 picassso 是否还有其他方法可以做到这一点

Picasso.with(context).load("http://192.168.0.15:1337/offers/" + image_url.get(position)).resize(350, 100).centerCrop().into(holder.imageView);
Run Code Online (Sandbox Code Playgroud)

现在在哪里设置图像上的文本。

android picasso

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