如何为通知RemoteView创建自定义Textview

时间:2017-11-06 12:49:01

标签: android push-notification android-custom-view

当我为{{crf_field()}}的布局添加自定义select: function(start, end, event, view, resource) { alert(resource.id) var resourceID = resource.id; // Display the modal. // You could fill in the start and end fields based on the parameters $('#NewCalModal').modal('show'); $('#NewCalModal').find('#Date').val(dateTimedd); $('#NewCalModal').find('#starts-at').val(dateTimett); $('#NewCalModal').find('#Location').val(roomLocation); // Whenever the user clicks on the "save" button om the dialog $('#save-event').on('click', function() { var title = $('#title').val(); var storedate = $('#Date').val(); var starttime = storedate + ' ' + $('#starts-at').val(); // whitespace allow the time to be read var endtime = storedate + ' ' + $('#ends-at').val(); if (title) { var eventData = { title: title, start: starttime, end: endtime, resourceId: resourceID }; $('#calendar').fullCalendar('renderEvent', eventData, true); // stick? = true } $('#calendar').fullCalendar('unselect'); // Clear modal inputs $('.modal').find('input').val(''); // hide modal $('.modal').modal('hide'); }); }, 时。它产生以下错误。

  

例外 - 从包中发布错误通知无法展开TextView

默认情况下RemoteViews它正常运行。

RemoteViews

2 个答案:

答案 0 :(得分:1)

import com.lokeshlabs.customviews.R;

public class MyButton extends AppCompatButton{

    private Context mContext;

    public MyButton(Context context) {
        super(context);
        init(context);
    }

    public MyButton(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public MyButton(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }

    public void init(Context context){
        mContext = context;
    }

    @Override
    protected void onDraw(Canvas canvas) {

        if(isPressed())
            setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.btn_pressed));
        else
            setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.btn_released));
        setTextColor(Color.parseColor("#eceff1"));

        super.onDraw(canvas);
    }

}

像在xml中一样识别

答案 1 :(得分:0)

您无法将自定义视图用于RemoteView。 RemoteView仅限于少数可能的小部件,特别是these documented用于通知。