好.我想要实现的是一种与Excel中的冻结窗格具有相同效果的布局.这就是我想要一个与主ListView水平滚动的标题行和一个与主ListView垂直滚动的左手ListView.当滚动到另一个维度时,标题行和左侧列表视图应保持静止.
这是xml布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/recordViewLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<LinearLayout android:layout_width="160dp"
android:layout_height="match_parent"
android:orientation="vertical">
<CheckBox
android:id="@+id/checkBoxTop"
android:text="Check All"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ListView android:id="@+id/engNameList"
android:layout_width="160dp"
android:layout_height="wrap_content"/>
</LinearLayout>
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout android:id="@+id/scroll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<include layout="@layout/record_view_line" android:id="@+id/titleLine" />
<ListView
android:id="@android:id/list"
android:layout_height="wrap_content"
android:layout_width="match_parent"/>
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
然后我在ListActivity中使用此代码
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
View v = recordsListView.getChildAt(0);
int top = (v == null) ? 0 : v.getTop();
((ListView)findViewById(R.id.engNameList)).setSelectionFromTop(firstVisibleItem, top);
}
Run Code Online (Sandbox Code Playgroud)
这应该导致左手ListView在用户滚动右手时滚动.不幸的是它没有.
我有一点关于google的事情,似乎setSelectionFromTop()函数不能在嵌套在多个布局中的ListView上运行.
如果是这种情况,任何人都可以建议一种方法来让它们一起滚动或以不同的方式来设置布局或完全不同的技术.
我有一个ListView,它使用自定义适配器,如下所示:
private class CBAdapter extends BaseAdapter implements OnCheckedChangeListener{
Context context;
public String[] englishNames;
LayoutInflater inflater;
CheckBox[] checkBoxArray;
LinearLayout[] viewArray;
private boolean[] checked;
public CBAdapter(Context con, String[] engNames){
context=con;
englishNames=engNames;
inflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
checked= new boolean[englishNames.length];
for(int i=0; i<checked.length; i++){
checked[i]=false;
//Toast.makeText(con, checked.toString(),Toast.LENGTH_SHORT).show();
}
checkBoxArray = new CheckBox[checked.length];
viewArray = new LinearLayout[checked.length];
}
public int getCount() {
return englishNames.length;
}
public Object getItem(int position) {
// TODO Auto-generated method stub
return null;
}
public long getItemId(int position) {
// TODO Auto-generated method stub …Run Code Online (Sandbox Code Playgroud) 我有一个我想要加载的文件格式,其中包含OpenGL对象的原始数据.
一切都会好,但数据编码为小端.
是否有一个java类完成DataInputStream的确切工作,但使用小端或者我必须逐字节加载它并自己执行转换?
这是我的代码:
sigTex = new Texture2D ((int)dims.x, (int)dims.y);
sigTex.ReadPixels (new Rect (new Vector2(0.0f, Screen.height - bot) , dims), 0, 0);
byte[] pngBytes = sigTex.EncodeToPNG ();
System.IO.BinaryWriter bw= new System.IO.BinaryWriter(new System.IO.FileStream(filename, System.IO.FileMode.Create));
bw.Write (pngBytes, 0, pngBytes.Length);
bw.Close ();
Run Code Online (Sandbox Code Playgroud)
问题是,在这段代码之后,当我尝试在 GUI 中使用它或在检查器中查看它时,我留下了一个空白纹理,它是统一的灰色。奇怪的是,生成的文件是正确的。