不知道为什么在布局中添加了却没有什么显示:
//界面更新
BookButton bookButton=new BookButton(SelectAty.this,newNote);
layout.addView(bookButton);
View源码:
public class BookButton extends RelativeLayout {
Note note;
TextView noteName;
public BookButton(Context context,Note note){
super(context);
this.note=note;
LayoutInflater.from(context).inflate(R.layout.book_button,this);
noteName=(TextView)findViewById(R.id.noteName);
noteName.setText(note.getNoteName());
}
//view的大小由note的大小决定
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec){
//没有效果?
setMeasuredDimension(150+note.getPagesNumber(),1000);
}
public void setNoteName(String noteName){
note.setNoteName(noteName);
//更改textView,完成界面的更新
this.noteName.setText(noteName);
}
public Note getNote(){
return note;
}
}
book_button.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@drawable/book1"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/noteName"
android:layout_centerInParent="true"
android:layout_width="15dp"
android:layout_height="50dp" />
</RelativeLayout>
求帮助。。。。。