小编Des*_*que的帖子

为什么set setBackgroundColor在我的自定义listView中不起作用

我有一个自定义listView.主要布局xml是这样的:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="horizontal"
  android:layout_width="match_parent"
  android:layout_height="match_parent">
    <ListView android:layout_height="wrap_content" 
              android:id="@+id/lv_clientes"
              android:layout_width="0dp">
    </ListView>
<!-- From this part there are not problems -->
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

列表项XML就是这样

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/rlo_elemento"
  android:layout_width="match_parent"
  android:layout_height="match_parent">
    <TextView android:id="@+id/tv_nombre"
              android:layout_width="wrap_content" 
              android:layout_height="wrap_content">
    </TextView>
    <!-- From this part there are not problems -->
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

现在适配器是这样的:

public class AdapterListaClientes extends BaseAdapter
{
    private Cliente[] data;
    Context context;
    LayoutInflater layoutInflater;
    int itemSelected = -1;

    public void setSelected(int valor)
    {
        itemSelected = valor;
    }

    public AdapterListaClientes(Context context, ArrayList<Cliente> data) …
Run Code Online (Sandbox Code Playgroud)

android listview adapter

18
推荐指数
1
解决办法
2万
查看次数

如何在Camel Processor中使用属性占位符

我正在用驼峰编写一些路由,我想使用处理器进行一些转换.我有一个属性文件,它工作正常.

    from(URI_LOG)
    .routeId("{{PREFIX_LOG}}.prepareForMQ") 
    .log("Mail to: {{MAIL}}") //The value is read from a property file
    .process(new ProcessorPrepareMail())
    .log("${body}");
Run Code Online (Sandbox Code Playgroud)

现在......我想在处理器内读取{{MAIL}}的值,但我不知道如何.

我试过这些东西:

public class ProcessorPrepareMail implements Processor
{

    @Override
    public void process(Exchange exchange) throws Exception
    {
        //Plan A: Does not work.... I get an empty String
        String mail = exchange.getProperty("MAIL", String.class);

        //Plan B: Does not work.... I get the String "{{MAIL}}"
        Language simple = exchange.getContext().resolveLanguage("simple");
        Expression expresion = simple.createExpression("{{MAIL}}");
        String valor = expresion.evaluate(exchange, String.class);

        //Plan C: Does not work. It activates the default …
Run Code Online (Sandbox Code Playgroud)

java integration apache-camel

6
推荐指数
1
解决办法
3315
查看次数

有时listView.getChildAt(int index)返回NULL(Android)

我有一个带有自定义适配器的listView.当某些事情发生时(点击一个孩子)我会做一些计算并修改子视图.如果某些条件已经满足,则应修改与被点击的孩子无关的其他孩子.

这有时会起作用,但有时会失败,DDMS会说视图为空...

我来告诉你代码:

        if(invalidaEste != -1)
        {
            try
            {
                View v = lv_data.getChildAt(invalidaEste);
                if( v== null)
                {
                    Log.e("MY_LOG", "SIZE " + lv_data.getCount());
                    Log.e("MY_LOG", "IS_NULL " + String.valueOf(invalidaEste)); 
                }

                if(invalidaEste >= lv_data.getFirstVisiblePosition() &&
                   invalidaEste <= lv_data.getLastVisiblePosition())
                {
                    RelacionFacturaPago rpf = (RelacionFacturaPago)lv_data.getAdapter().getItem(invalidaEste);
                    TextView tv = (TextView)v.findViewById(R.id.tv_pendiente);
                    tv.setText(Formato.double2Screen(rpf.getPorPagar()));
                }
            }
            catch (Exception e)
            {
                Log.e("MY_LOG", "FAIL");
                Log.e("MY_LOG", String.valueOf(invalidaEste));
            }

        }
Run Code Online (Sandbox Code Playgroud)

invalidaEste是我想要修改的视图.当v为null时,我记录索引以检查它是否正常.始终小于或等于listView.getCount()

为什么会这样?

更多数据:代码位于AnimationListener侦听器的onAnimationStart(动画动画)内.

android view android-listview

5
推荐指数
1
解决办法
2万
查看次数

滚动时多个布局的ListView崩溃

我有一个自定义适配器来显示无聊的东西列表.现在,我想添加一个带有摘要(Resumen)的最后一项.

我使用两个布局和两个视图,它有点工作 在此输入图像描述

当我滚动回第一个项目时问题开始了.当"Resumen"项目消失(最后一个)时,活动崩溃.

让我告诉你适配器代码(相关的行)

public class AdapterListaDeudaCliente extends BaseAdapter
{
    final private int VIEW_TYPES = 2;
    final private int TIPO_FACTURA = 1;
    final private int TIPO_RESUMEN = 2;

    public int getViewTypeCount()
    {
        return VIEW_TYPES; 
    }

    public int getItemViewType(int position) 
    {
        if(position%2==0)
            return TIPO_RESUMEN;
        else
            return TIPO_FACTURA;
    }

    public int getCount()
    {
        return data.length;
    }

    public View getView(int position, View convertView, ViewGroup parent)
    {
         int tipo = getItemViewType(position);
            switch(tipo)
            {
                case TIPO_FACTURA: convertView = layoutInflater.inflate(R.layout.elemento_deuda_basico, null);
                                                 break;
                case TIPO_RESUMEN: convertView …
Run Code Online (Sandbox Code Playgroud)

android adapter android-layout

2
推荐指数
1
解决办法
1681
查看次数