mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-22 09:01:57 -05:00
Server list now changes colour for clicked row
This commit is contained in:
parent
069325fcf8
commit
7b733e610c
1 changed files with 34 additions and 16 deletions
|
@ -57,6 +57,7 @@ import android.view.inputmethod.EditorInfo;
|
|||
import android.view.inputmethod.InputConnection;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.AbsoluteLayout;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.Button;
|
||||
|
@ -71,8 +72,6 @@ import android.widget.ProgressBar;
|
|||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.classicube.android.client.R;
|
||||
|
||||
// This class contains all the glue/interop code for bridging ClassiCube to the java Android world.
|
||||
// Some functionality is only available on later Android versions - try {} catch {} is used in such places
|
||||
// to ensure that the game can still run on earlier Android versions (albeit with reduced functionality)
|
||||
|
@ -805,10 +804,27 @@ public class MainActivity extends Activity
|
|||
View.SCROLL_INDICATOR_START |
|
||||
View.SCROLL_INDICATOR_END);
|
||||
list.setScrollbarFadingEnabled(false);*/
|
||||
final CCTableAdapter adapter = new CCTableAdapter(MainActivity.this);
|
||||
// https://stackoverflow.com/questions/2454337/why-is-my-onitemselectedlistener-not-called-in-a-listview
|
||||
|
||||
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
View prev;
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (prev != null) {
|
||||
int prevPos = list.getPositionForView(prev);
|
||||
if (prevPos >= 0)
|
||||
prev.setBackgroundColor(adapter.getRowColor(prevPos, false));
|
||||
}
|
||||
|
||||
prev = view;
|
||||
view.setBackgroundColor(adapter.getRowColor(position, true));
|
||||
}
|
||||
});
|
||||
|
||||
return showWidgetAsync(list, lp, new UICallback() {
|
||||
public void execute() {
|
||||
CCTableAdapter adapter = new CCTableAdapter(MainActivity.this, list.getId());
|
||||
list.setAdapter(adapter);
|
||||
}
|
||||
});
|
||||
|
@ -849,11 +865,9 @@ public class MainActivity extends Activity
|
|||
{
|
||||
public Object[] entries = new Object[0];
|
||||
Context ctx;
|
||||
int listID;
|
||||
|
||||
public CCTableAdapter(Context context, int id) {
|
||||
public CCTableAdapter(Context context) {
|
||||
ctx = context;
|
||||
listID = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -884,11 +898,15 @@ public class MainActivity extends Activity
|
|||
title.setText(entry.title);
|
||||
details.setText(entry.details);
|
||||
|
||||
int color = tableGetColor(position, false, entry.featured);
|
||||
convertView.setBackgroundColor(color);
|
||||
convertView.setBackgroundColor(getRowColor(position, false));
|
||||
return convertView;
|
||||
}
|
||||
|
||||
public int getRowColor(int position, boolean selected) {
|
||||
TableEntry entry = (TableEntry)entries[position];
|
||||
return tableGetColor(position, selected, entry.featured);
|
||||
}
|
||||
|
||||
View createRow(int position) {
|
||||
ImageView image = new ImageView(ctx);
|
||||
LinearLayout.LayoutParams imageLP = new LinearLayout.LayoutParams(
|
||||
|
|
Loading…
Reference in a new issue