小编nif*_*ody的帖子

按(单击)按钮时调用(ngSubmit)

我的Angular2表单组件上有两个按钮.按钮正在执行自己的功能.

  1. 按钮提交:哪个提交API的所有值.
  2. 按钮添加.:将对象推送到数组.

这两种方法都在这里......

onSubmit() {
this.submitted = true;
this.model.service_requests = this.modelJobServices;
this.onCreateJob();
}

addJobService(modelJobService :Jobservice){
let modelJobServiceLocal = new Jobservice(modelJobService.service_id,modelJobService.service_note,modelJobService.status)
this.modelJobServices.push(modelJobServiceLocal);
}
Run Code Online (Sandbox Code Playgroud)

我的Component.html结构如下

<form #jobRegistrationForm="ngForm" (ngSubmit)="onSubmit()">
......
......
......
<button class="flat btn-primary form-control" id="btn_add" (click)="addJobService(modelJobService)"> ADD SERVICE </button>
....
....
....
<button (submit)="onSubmit()" [disabled]="!jobRegistrationForm.form.valid" class="flat form-control col-md-4 btn-primary">{{BUTTON_TEXT}}</button>
Run Code Online (Sandbox Code Playgroud)

当我按下(click)按钮时,表单将提交给API调用.但我没有打电话onSubmit()(click)按钮事件

typescript angular

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

在Android的OKhttp中通过POST请求发送JSON正文

我已经设置了OkHttpClient并成功将GET请求发送到服务器.而且我还能够将POST请求发送到具有空body标签的服务器.

现在,我正在尝试将以下JSON对象发送到服务器.

{
"title": "Mr.",
"first_name":"Nifras",
"last_name": "",
"email": "nfil@gmail.com",
"contact_number": "75832366",
"billing_address": "",
"connected_via":"Application"
}
Run Code Online (Sandbox Code Playgroud)

为此,我尝试添加OkHttpClient库类,RequestBody但是我无法将JSON对象作为http POST请求的主体发送.以下方法我尝试构建主体并处理发布请求.

OkHttpClient client = new OkHttpClient();

    RequestBody body = new RequestBody() {
        @Override
        public MediaType contentType() {
            return ApplicationContants.JSON;
        }

        @Override
        public void writeTo(BufferedSink sink) throws IOException {
              // This is the place to add json I thought. But How could i do this
        }
    };

    Request request = new Request.Builder()
            .url(ApplicationContants.BASE_URL + ApplicationContants.CUSTOMER_URL)
            .post(body)
            .build();
Run Code Online (Sandbox Code Playgroud)

我通过POST请求将JSON对象发送到服务器的方式是什么.

提前致谢.

android json okhttp okhttp3

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

使用自定义拨号程序功能隐藏传入的电话号码

我计划使用拨号功能来隐藏来电者的ID.我有一个应用程序,呼叫者的电话号码嵌入在"拨号"按钮中.

在应用程序中,双方(呼叫者和接收者)可以看到他们自己的号码.

我使用以下代码进行默认调用:

Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse(“tel:”+mNumberEditText.getText().toString()));
startActivity(callIntent);
Run Code Online (Sandbox Code Playgroud)

我的问题是隐藏双方的号码.我该怎么做呢?

在此输入图像描述

android android-support-library

5
推荐指数
0
解决办法
468
查看次数

检查图片框值是否为空

我使用Visual Studio IDE开发了一个可视化的C#窗体应用程序.

我的问题是如何检查用户是否选择了图像.

我粗略地检查图像像一个字符串,整数对象,但它不起作用

if(myPictureBox.Image == NULL){
    //The Image is Null
}
Run Code Online (Sandbox Code Playgroud)

c# winforms

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

无法调用 runOnUiThread()

我有一个名为 的片段MyRequestFragment,其中包含使用我的适配器类RecyclerView将数据绑定到RecyclerViewusing的片段onBindViewHolder()

现在每个ViewHolder我都有一个按钮。并且每次单击按钮都会POST向服务器发出请求并更新值。我的问题是,如果出现成功响应,我需要隐藏特定ViewHolder.

实际问题是runOnUiThread()不接受onBindViewHolder()

runOnUiThread(new Runnable() {
    public void run() {

    }
});
Run Code Online (Sandbox Code Playgroud)

我如何在ViewHolder创建/绑定方法中调用它。

我的onBindViewHolder()完整代码如下供参考。

@Override
    public void onBindViewHolder(MyServiceViewHolder holder, int position) {
        final MyServiceBean myServiceBean = serviceList.get(position);
        holder.service_name.setText(myServiceBean.getService_name());
        holder.last_updated.setText("Job Updated Date : " +myServiceBean.getDate(myServiceBean.getUpdated_at()));
        holder.created_date.setText("Job Created Date : " + myServiceBean.getDate(myServiceBean.getCreated_at()));
        holder.status.setText(myServiceBean.getStatus());
        holder.service_note.setText("Service Note : " + myServiceBean.getService_note());
        if (myServiceBean.getService_note().toString().isEmpty())
            holder.service_note.setVisibility(View.GONE);

        switch (myServiceBean.getStatus().toString().toLowerCase()) {
            case "completed":
                holder.status.setBackgroundColor(Color.GREEN);
                break; …
Run Code Online (Sandbox Code Playgroud)

android android-viewholder okhttp3

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

如何在xml布局中调用String-array值

我在我的string res/value文件夹中的string.xml文件中有一个字符串数组

我的string.xml

<string-array name="books_titles_en">
    <item>Smoking Effeccts on Your Body</item>
    <item>Smoking - effects on your body</item>
    <item>How Tobacco Smoke Causes Disease</item>
    <item>patterns of use, health effects, use in smoking cessation and regulatory issues</item>
</string-array>
Run Code Online (Sandbox Code Playgroud)

我需要像这样检索数组的第一个元素

我的home.xml

 <TextView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:paddingLeft="@dimen/frag_1_text_pad"
                android:textSize="@dimen/frag_1_text_size"
                android:paddingRight="@dimen/frg_1_text_right_pad"
                android:id="@+id/book_link0"
                android:text="@string-array/book_title_en[0]"/>
Run Code Online (Sandbox Code Playgroud)

我知道它似乎会导致错误.如何在Android中的string.xml中的字符串数组上检索这些内容

xml arrays android android-layout

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