RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-214548

cherry's questions

Martin Hope
cherry
Asked: 2020-07-05 18:45:38 +0000 UTC

如何使 RecyclerView 可加载?[复制]

  • 1
这个问题已经在这里得到回答:
在 RecyclerView 中加载数据 (3 个答案)
5 年前关闭。

如何像 Instagram 一样制作可加载的 RecyclerView?这样当到达列表末尾时,加载另一条数据。

recyclerview
  • 1 个回答
  • 10 Views
Martin Hope
cherry
Asked: 2020-06-30 16:03:10 +0000 UTC

如何从服务器获取布尔类型的响应,errors(402,...)?Android HttpUrlConnection

  • 0

我正在使用 HttpUrlConnection 与服务器通信。

        InputStream is = null;
        String parammetrs =  "clientId=" + client.getId() + "&bikeId=" + 1;
        BufferedReader br = null;
        String json = null;
        try {
            URL url = new URL(myURL);
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("POST");
            connection.setDoOutput(true);
            connection.setDoInput(true);
            connection.setRequestProperty("content-type", "application/x-www-form-urlencoded");
            connection.getOutputStream().write(parammetrs.getBytes("UTF-8"));
            is = connection.getInputStream();
            br = new BufferedReader(new InputStreamReader(is));
            json = (br.readLine().toString()); 
           } catch (MalformedURLException e) {
            e.printStackTrace();

        } catch (ProtocolException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();

        }

        return json;
    }

OnPostExecute 对我来说仍然是空的。如何从服务器获取布尔响应、错误 (402, ...)?

android
  • 1 个回答
  • 10 Views
Martin Hope
cherry
Asked: 2020-06-30 04:40:33 +0000 UTC

解析缺少字段的 Json。异步任务.OnPostExecute

  • 2

我使用 AsyncTask 从 Internet 下载数据的位置有 url1 和 url2。Json 字段类似。唯一区别它们的是 url2 在 json 中没有 end_time 字段。我用一个 AsyncTask 启动两个 url。第一个 url 输出 Recyclerview 中的所有内容,而第二个则没有。我试着把

if(jsonObject.getString("end_time")!=null)  

也

if(jsonObject.getString("end_time")!="")

仍然不起作用。

我需要创建两个单独的 AsyncTasks 还是有其他方法?

android
  • 2 个回答
  • 10 Views
Martin Hope
cherry
Asked: 2020-06-26 18:18:02 +0000 UTC

更改选项菜单的背景颜色?

  • 0

现在菜单的背景色为黑色。我想把它改成绿色。我试过了android:background="#00FF00"。不改变。

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".MainActivity"
android:background="#00FF00"
>

<item
    android:id="@+id/newrent"
    android:title="@string/action_new_rent"
    app:showAsAction="never"/>

<item
    android:id="@+id/deleteme"
    android:title="@string/action_delete_me"
    app:showAsAction="never"/>
</menu>
android
  • 1 个回答
  • 10 Views
Martin Hope
cherry
Asked: 2020-06-14 04:09:36 +0000 UTC

Resources$NotFoundException,Recyclerview 看不到标记

  • 0

在第 44 行抛出错误 Resources$NotFoundException holder.id.setText(record.getId());

public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.ViewHolder> {

private ArrayList<Record> records =  new ArrayList();


public RecyclerViewAdapter(Context context, ArrayList<Rents> arrayList) {
    super();
    this.records= arrayList;
}

@Override
public RecyclerViewAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.records_item, parent, false);

    return  new ViewHolder(v);

}

@Override
public void onBindViewHolder(ViewAdapter.ViewHolder holder, int position) {
    Records record = records.get(position);
    Log.e("TEST",""+record.getId());

    holder.id.setText(record.getId());
}

@Override
public int getItemCount() {
    return records.size();
}

class ViewHolder extends RecyclerView.ViewHolder {

    private TextView id;

    public ViewHolder(View itemView) {

        super(itemView);
         id = (TextView)itemView.findViewById(R.id.record_id);
     }
   }
 }

A 是 XML records_item

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
android:id="@+id/record_image"
android:src="@mipmap/ic_launcher"
android:layout_margin="15dp"
android:layout_width="50dp"
android:layout_height="50dp" />
<TextView
    android:id="@+id/record_id"
    android:textColor="#000000"
    android:layout_toRightOf="@id/record_image"
    android:layout_alignTop="@id/record_image"
    android:layout_marginRight="10dp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

recyclerview
  • 1 个回答
  • 10 Views
Martin Hope
cherry
Asked: 2020-02-24 11:55:54 +0000 UTC

一个安卓应用的两个界面

  • 0

有两种类型的用户(服务和客户)。输入登录时,应用程序必须判断用户属于什么类型,并打开相应的界面。客户应该显示菜单,服务应该有订单列表。请帮我解决这个问题。如何实施?

android
  • 1 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5