Find controls in a separate class from the main Activity

1

I need to look for controls to change values in the layout. However passing the context per parameter to the class it does not find controls declared in xml returning null for each cast done.

The class where I'm trying to retrieve this data extends AsyncTask:

public class WSCatalogo91 extends AsyncTask<Void, ProgressAux, Boolean> 

private ProgressBar mProgressBar;
private TextView mProgressText;

public WSCatalogo91(WSCatalogo91Listener listener) throws SQLException {
        this.listener = listener;
        dh = new DatabaseHelper((Activity) listener);
        confDao = new ConfiguracaoDao(dh.getConnectionSource());
        pDao = new ProdutoDao(dh.getConnectionSource());

        mProgressBar = (ProgressBar) ((Activity) listener).findViewById(R.id.progressBar);
        mProgressText = (TextView) ((Activity) listener).findViewById(R.id.progressBarTextView);
        auxProgresso = new ProgressAux();
    }

mProgressBar and mProgressText are null, but my context ai is not null, so much so that it is being used in the top rows perfectly. Here is the xml code where I declare the ids.

<TextView android:text="@string/progressBar" android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:id="@+id/progressBarTextView"
        android:maxWidth="400dp"
        android:maxHeight="400dp"/>

    <ProgressBar
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/progressBar"
        android:indeterminate="false"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="165dp"
        android:minWidth="300dp" />
    
asked by anonymous 01.12.2014 / 18:26

0 answers