相关疑难解决方法(0)

ListView项目选择状态不起作用

所以我有一个ListView,我想改变每个项目背景和文本的颜色.此ListView位于ListFragment中.我的代码膨胀了布局,onCreateView并膨胀了每个项目的布局newView.

android:state_pressed="true"工作正常,每当我在一个项目按背景变为彩色.但是当选择一个项目时,bg颜色或文本颜色都没有变化,即使我已经android:state_selected="true"在选择器中定义了一个项目.

编辑:我正在使用SDK级别11(Android 3.0)和摩托罗拉Xoom.

列表片段布局:

<?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:id="@android:id/list"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

列表项布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:padding="25dp"
    android:background="@drawable/list_item_bg_selector">
    <TextView android:id="@+id/form_title"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:textSize="@dimen/text_size_xlarge"
        android:textStyle="bold"
        android:textColor="@drawable/list_item_text_selector" />
    <TextView android:id="@+id/form_subtitle"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:textSize="@dimen/text_size_medium"
        android:textStyle="normal"
        android:layout_marginTop="5dp"
        android:textColor="@drawable/list_item_text_selector" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

背景选择器:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item 
        android:state_pressed="true"
        android:drawable="@color/white" />
    <item
        android:state_selected="true"
        android:drawable="@drawable/list_item_bg_selected" />
    <item 
        android:drawable="@color/list_bg" />
</selector>
Run Code Online (Sandbox Code Playgroud)

文字选择器:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:state_selected="true"
        android:drawable="@color/white" /> …
Run Code Online (Sandbox Code Playgroud)

android listview android-layout

21
推荐指数
1
解决办法
3万
查看次数

适当的矩阵乘法用于旋转/平移

关于任意点的旋转和平移

为了旋转/平移物体(仅绕z轴旋转和仅在xy平面上平移)不仅仅是wrt到全局中心(设备中心)而且还有其他任意点,我创建了一个算法,这是正确的(因为所有高级我已经讨论过的编码器认为它是正确的),但是在实现中删除不需要的翻译需要花费很多时间(算法是在8月4日创建的,并且是在同一天实现的,从那以后代码被修改了15次).

这是http://www.pixdip.com/opengles/transform.php#ALGO1的实现

产生不希望的翻译的代码行在里面:

private static void updateModel(int upDown, float xAngle, float yAngle, float zAngle) {

并列出如下:

  1. Matrix.multiplyMV(GLES20Renderer._uBodyCentreMatrix, 0, GLES20Renderer._ModelMatrixBody, 0, GLES20Renderer._uBodyCentre, 0);

  2. objX = GLES20Renderer._uBodyCentreMatrix[0];

  3. objY = GLES20Renderer._uBodyCentreMatrix[1];

即使进行了以下更改,沿着+ Y的不期望的转换仍然存在:

  1. objY = _uBodyCentreMatrix[1] - _uBodyCentre[1];

  2. zAngle = 0;

  3. ds = 0;

由于Renderer类的这些字段,-0.545867f每次调用时都会将值添加到Y坐标onDrawFrame():

private static final float[] _uBodyCentre = new float[]{-0.019683f, -0.545867f, -0.000409f, 1.0f};

protected static float[] _uBodyCentreMatrix = new float[4];

http://www.pixdip.com/opengles/transform.php#FIELDS中

我需要帮助才能理解为什么不希望的翻译发生,转换的确切错误,或者算法是错误的.

万向锁可以成为一个问题吗?

请不要让我执行/练习更简单的示例,因为我准备了Renderer类来进行关于全局z轴的旋转/转换,而我所进入的这个新任务使用相同的类,稍作修改 updateModel()

(请注意,所需的旋转仅约为z轴,仅在xy平面内平移)

[API 10-> 15] …

android opengl-es linear-algebra opengl-es-2.0

19
推荐指数
2
解决办法
2340
查看次数