qq_22200361
cjunl
采纳率0%
2016-03-06 03:11 浏览 14.0k

Attempt to invoke virtual method

public class SecondView extends LinearLayout {
private TextView tv_hour,tv_minute,tv_second,tv_millisecond;
private ListView mListView;
private ArrayAdapter adapter;
private Button btn_start,btn_pause,btn_reset,btn_resume,btn_lap;

public SecondView(Context context) {
    super(context);
}

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

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

@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    init();
}

public void init(){
    btn_lap = (Button) findViewById(R.id.btn_lap);
    btn_pause = (Button) findViewById(R.id.btn_pause);
    btn_reset= (Button) findViewById(R.id.btn_reset);
    btn_resume = (Button) findViewById(R.id.btn_resume);
    btn_start = (Button) findViewById(R.id.btn_start);

    btn_start.setVisibility(VISIBLE);
    btn_resume.setVisibility(GONE);
    btn_reset.setVisibility(GONE);
    btn_pause.setVisibility(GONE);
    btn_lap.setVisibility(GONE);

    tv_hour = (TextView) findViewById(R.id.tvHour);
    tv_millisecond = (TextView) findViewById(R.id.tvMilisecond);
    tv_minute = (TextView) findViewById(R.id.tvMinute);
    tv_second = (TextView) findViewById(R.id.tvSecond);

    mListView = (ListView) findViewById(R.id.lvWatching);
    adapter = new ArrayAdapter(getContext(),android.R.layout.simple_list_item_1);
    mListView.setAdapter(adapter);
}

}

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答 默认 最新

  • qq_17250009 一口仨馍 2016-03-06 11:58

    先使用LayoutInflater.inflate 然后再findViewByid

    点赞 评论 复制链接分享

相关推荐