Note that there are some explanatory texts on larger screens.

plurals
  1. POandroid class cast excp relative layout
    text
    copied!<p>i am getting class cast exception relative$layout here is the code</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;RelativeLayout android:layout_height="wrap_content" android:id="@+id/relativeLayout1" android:layout_width="fill_parent"&gt; &lt;Button android:text="Delete" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/Button2" android:layout_alignParentTop="true" android:layout_alignParentRight="true"&gt;&lt;/Button&gt; &lt;Button android:text="Edit" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/button1" android:layout_alignParentTop="true" android:layout_toLeftOf="@+id/Button2"&gt;&lt;/Button&gt; &lt;TextView android:text="TextView" android:id="@+id/textView1" android:layout_height="wrap_content" android:layout_width="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:layout_alignParentTop="true" android:layout_alignParentLeft="true" android:layout_toLeftOf="@+id/button1"&gt;&lt;/TextView&gt; &lt;/RelativeLayout&gt; &lt;/LinearLayout&gt; </code></pre> <p>.</p> <pre><code>import java.util.List; import android.app.ExpandableListActivity; import android.content.Context; import android.os.Bundle; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AbsListView; import android.widget.BaseExpandableListAdapter; import android.widget.ExpandableListAdapter; import android.widget.TextView; public class options extends ExpandableListActivity { ExpandableListAdapter mAdapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.list); mAdapter = new MyExpandableListAdapter(); setListAdapter(mAdapter); } public class MyExpandableListAdapter extends BaseExpandableListAdapter{ private String[] groups = { "People Names", "Dog Names", "Cat Names", "Fish Names" }; private String[][] children = { { "Arnold", "Barry", "Chuck", "David" }, { "Ace", "Bandit", "Cha-Cha", "Deuce" }, { "Fluffy", "Snuggles" }, { "Goldy", "Bubbles" } }; @Override public Object getChild(int groupPosition, int childPosition) { return children[groupPosition][childPosition]; } @Override public long getChildId(int groupPosition, int childPosition) { return childPosition; } @Override public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { TextView textView = getGenericView(); textView.setText(getChild(groupPosition, childPosition).toString()); return textView; } @Override public int getChildrenCount(int groupPosition) { return children[groupPosition].length; } @Override public Object getGroup(int groupPosition) { return groups[groupPosition]; } @Override public int getGroupCount() { return groups.length; } @Override public long getGroupId(int groupPosition) { return groupPosition; } @Override public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { TextView textView = getGenericView(); textView.setText(getGroup(groupPosition).toString()); return textView; } @Override public boolean hasStableIds() { return true; } @Override public boolean isChildSelectable(int groupPosition, int childPosition) { return true; } public TextView getGenericView() { // Layout parameters for the ExpandableListView //AbsListView.LayoutParams lp = new AbsListView.LayoutParams( // ViewGroup.LayoutParams.FILL_PARENT, 64); //TextView textView = new TextView(options.this); // textView.setLayoutParams(lp); // Center the text vertically // textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT); // Set the text starting position //textView.setPadding(60, 0, 0, 0); //TextView textView = (TextView) findViewById(R.id.textView1); //return textView; LayoutInflater inflater = (LayoutInflater)options.this.getSystemService (Context.LAYOUT_INFLATER_SERVICE); View v = inflater.inflate(R.layout.row, null); TextView textView = (TextView) v.findViewById(R.id.textView1); return textView; } } } </code></pre> <p>in the last getGenericView() code in comment works fine but i am trying to inflate from row.xml which gives me error.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload