0
E/AndroidRuntime(5149):android.view.InflateException:バイナリXMLファイル行#44:エラーが発生しましたクラスcom.android.demoapp.View.GridCustomView E/AndroidRuntime(5149):android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:757)android.view.InflateException:バイナリXMLファイル行#44:inflate class com.android.demoapp.View.GridCustomView
で....
<com.android.demoapp.customView.GridCustomView
android:id="@+id/myId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:horizontalSpacing="2dp"
android:isScrollContainer="false"
android:numColumns="4"
android:stretchMode="columnWidth"
android:verticalSpacing="20dp" />
アダプタビューを作成する:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// Check if an existing view is being reused, otherwise inflate the view
ContactBlock user = getItem(position);
if(convertView==null)
{
convertView = inflter.inflate(R.layout.viewtemplate,null);
}
conviewname = (TextView) convertView.findViewById(R.id.conname);
conviewnumb = (TextView) convertView.findViewById(R.id.connumber);
// TextView al = (TextView) convertView.findViewById(R.id.alpha);
// grid = (GridView) convertView.findViewById(R.id.grid_view);
gridCustomView = (GridCustomView) convertView.findViewById(R.id.myId);
gridCustomView.setExpanded(true);
//al.setText(user.name.substring(0, 1));
// al.setText(alpha);
conviewname.setText(user.getInitial().toUpperCase());
//conviewnumb.setText(""+user.getContacts().size());
gridadapter= new GridAdapter(context, user.getContacts());
// grid.setAdapter(gridadapter);
gridCustomView.setAdapter(gridadapter);
return convertView;
}
......................
public class GridCustomView extends GridView {
boolean expanded = false;
public GridCustomView(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public GridCustomView(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
public GridCustomView(Context context, AttributeSet attrs, int defaultStyle) {
super(context);
}
public boolean isExpanded() {
return expanded;
}
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// HACK! TAKE THAT ANDROID!
if (isExpanded()) {
// Calculate entire height by providing a very large height hint.
// viewCustom.MEASURED_SIZE_MASK represents the largest height possible.
int expandSpec = MeasureSpec.makeMeasureSpec(MEASURED_SIZE_MASK,
MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, expandSpec);
ViewGroup.LayoutParams params = getLayoutParams();
params.height = getMeasuredHeight();
} else {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
public void setExpanded(boolean expanded) {
this.expanded = expanded;
}
}
エラーなしは同じまま –
ください。編集したコードをチェックしてください!! –
いいえ.....エラーは同じままです:( –