package tech.together.Character.Components;
import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import java.util.List;
import tech.together.R;
/**
-
Created by think on 2016/6/5.
*/
public class BecomeEmployeeSkills extends LinearLayout implements View.OnClickListener {private LinearLayout skills;
//private LayoutParams param = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
private LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
private List editSkillsViews;
public BecomeEmployeeSkills(Context context) {
super(context);
initView(context);
}public BecomeEmployeeSkills(Context context, AttributeSet attrs) {
super(context, attrs);
initView(context);
}private void initView(Context context) {
View.inflate(context, R.layout.layout_become_employee_skills, this);findViewById(R.id.add).setOnClickListener(this); findViewById(R.id.submit).setOnClickListener(this); skills = (LinearLayout) findViewById(R.id.skills);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.add:
//TODO 使用EditSkillView
Log.d("URL", "onClick()ADD");
View view2 = (LinearLayout) LayoutInflater.from(getContext()).inflate(R.layout.view_edit_skill, skills, false);
view2.setLayoutParams(param);
skills.addView(view2);
invalidate();
skills.requestLayout();
break;
case R.id.submit:
//TODO
break;
}
}
}
addView后用手机测试,点击按钮没有反应,也不报错,然后输出的是下面的log
06-07 09:47:39.350 8325-8325/tech.together D/URL: onClick()ADD
06-07 09:47:39.366 8325-8325/tech.together D/ColorDrawable: Color = -1118482, canvas = android.view.GLES20RecordingCanvas@2d50567e, mTintMode = SRC_IN, mTint = null, ColorDrawable = android.graphics.drawable.ColorDrawable@3e3c5c62
06-07 09:47:39.544 8325-8325/tech.together V/SettingsInterface: from settings cache , name = sound_effects_enabled , value = 0
0
真不知道是为什么原因,求解释!