Не совсем уверен, что здесь происходит, поэтому я надеюсь, что один из вас может указать мне правильное направление. У меня есть ListView внутри фрейма Tab и по какой-то причине он загружается, но вылетает при попытке прокрутки.
Вот вся информация, которую я мог собрать
Вот действие, которое входит во фрейм ... он анализирует файл XML в очередь с приоритетами, получает информацию о прикрепленном намерении и загружает нужную страницу.
public class QScoresFrameActivity extends ListActivity
{
private PriorityQueue<Score> mScores;
private int mDifficulty;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.scoresframe);
mDifficulty = getIntent().getIntExtra(getResources().getString(R.string.difficulty), getResources().getInteger(R.integer.normal_level));
mScores = QGameGlobals.ParseScoresXML(this,mDifficulty);
setListAdapter(new ScoresAdapter(this));
}
private class ScoresAdapter extends BaseAdapter
{
private LayoutInflater mInflater;
public ScoresAdapter(Context context)
{
mInflater = LayoutInflater.from(context);
}
public View getView(int position, View convertView, ViewGroup parent)
{
Score thisScore = mScores.getByIndex(position);
convertView = mInflater.inflate(R.layout.scoreview, null);
TextView posT;
TextView nameT;
TextView scoreT;
String name = thisScore.getName();
int score = thisScore.getScore();
posT = (TextView)convertView.findViewById(R.id.position);
nameT = (TextView)convertView.findViewById(R.id.scorerName);
scoreT= (TextView)convertView.findViewById(R.id.scorerScore);
posT.setText(String.valueOf(position + 1) + ". ");
nameT.setText(name);
scoreT.setText(String.valueOf(score));
return convertView;
}
public int getCount()
{
return mScores.getLength();
}
public Object getItem(int position)
{
return this;
}
public long getItemId(int position)
{
return position;
}
}
}
Файл макета, содержащий список:
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:orientation="vertical">
<ListView android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+android:id/list" />
</LinearLayout>
Файл макета для каждого элемента в списке:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/linearLayout1" android:padding="10dp" android:layout_width="fill_parent" android:baselineAligned="false" android:orientation="horizontal" android:layout_height="wrap_content">
<TextView android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" android:text="TextView" android:paddingRight="10dp" android:id="@+id/position" android:layout_width="50dp" android:textColor="@color/teal" ></TextView>
<TextView android:id="@+id/scorerName" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text="TextView" android:layout_width="wrap_content" android:layout_gravity="center_vertical"></TextView>
<TextView android:id="@+id/scorerScore" android:text="TextView" android:textAppearance="?android:attr/textAppearanceLarge" android:paddingLeft="20dp" android:layout_height="wrap_content" android:gravity="right" android:textColor="@color/gold" android:layout_width="match_parent" android:layout_gravity="center_vertical"/>
</LinearLayout>
Класс очереди приоритетов ....
@SuppressWarnings("rawtypes")
public class PriorityQueue<T extends Comparable> extends Queue<T>
{
public PriorityQueue ()
{
super();
}
@SuppressWarnings("unchecked")
@Override
public void enqueue(T item)
/* Enqueue a new object of type T into the queue based on its compareTo method.
* Sorts from greatest to least.
*/
{
TNode newNode = new TNode(item);
if (root == null)
{
root = newNode;
end = newNode;
}
else
{
TNode currNode = root;
TNode lastNode = root;
while (true)
{
int compVal = item.compareTo(currNode.get());
if (compVal == 1 || compVal == 0)
{
if (currNode == root)
{
root = newNode;
}
else
{
lastNode.next = newNode;
newNode.next = currNode;
}
newNode.next = currNode;
break;
}
else
{
if (currNode == end)
{
currNode.next = newNode;
end = newNode;
break;
}
else
{
lastNode = currNode;
currNode = currNode.next;
}
}
}
}
length++;
}
}
Ценю помощь.