Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6181307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:59:47+00:00 2026-05-24T00:59:47+00:00

everyone, i’ve a little problem how to use variable from another class file to

  • 0

everyone, i’ve a little problem how to use variable from another class file to App Widget.

Here, my little sourcecode :

TimeKu.Java :

public class TimeKu extends Activity {
private ListView lvUsers;
private ArrayList<UserAP> mListUsers;


@Override
public void onCreate(Bundle savedInstanceState) {
  .....            

}

public ArrayList<UserAP> getUsers(){                

    DBAdapter dbAdapter=DBAdapter.getDBAdapterInstance(this);
    try {
        dbAdapter.createDataBase();
    } catch (IOException e) {
        Log.i("*** select ",e.getMessage());
    }
    dbAdapter.openDataBase();
    //query langsung ke database di sistem buat perbandingan
    String query="SELECT * FROM ********** WHERE date(tanggal) = date('now')";
    ArrayList<ArrayList<String>> stringList = dbAdapter.selectRecordsFromDBList(query, null);
    dbAdapter.close();

    ArrayList<UserAP> usersList = new ArrayList<UserAP>();
    for (int i = 0; i < stringList.size(); i++) {
        ArrayList<String> list = stringList.get(i);
        UserAP user = new UserAP();
        try {
            user.tanggal = list.get(1);
            user.xyz = list.get(2);
            user.abc = list.get(3);
        } catch (Exception e) {
            Log.i("***" + TimeKu.class.toString(), e.getMessage());
        }
        usersList.add(user);
    }
    return usersList;
}

    // ***ListAdapter***
public class ListAdapter extends ArrayAdapter<UserAP> { 
    private ArrayList<UserAP> mList; 
    private Context mContext;

    public ListAdapter(Context context, int textViewResourceId,ArrayList<UserAP> list) { // --CloneChangeRequired
        super(context, textViewResourceId, list);
        this.mList = list;
        this.setmContext(context);
    }

    public View getView(int position, View convertView, ViewGroup parent){
        View view = convertView;
        try{
        if (view == null) {
            LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            view = vi.inflate(R.layout.list_item, null);    
        }
        final UserAP listItem = mList.get(position);                
        if (listItem != null) {
            // konfigurasi list view dari konten di database                        
            ( (TextView) view.findViewById(R.id.tgl) ).setText( listItem.getTanggal()+"");
            ( (TextView) view.findViewById(R.id.xyz) ).setText( listItem.getXYZ()+"");
            ( (TextView) view.findViewById(R.id.abc) ).setText( listItem.getABC()+"");

        }}catch(Exception e){
            Log.i(TimeKu.ListAdapter.class.toString(), e.getMessage());             
        }
        return view;
    }

    public void setmContext(Context mContext) {
        this.mContext = mContext;
    }

    public Context getmContext() {
        return mContext;
    }

}

}

And HelloWidget.Java :

 public class HelloWidget extends AppWidgetProvider {
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
int[] appWidgetIds) {
    Timer timer = new Timer();
    ArrayList<UserAP> list = null;
    timer.scheduleAtFixedRate(new MyTime(context, list, appWidgetManager), 1, 1000);
}

private class MyTime extends TimerTask {
    RemoteViews remoteViews;
    AppWidgetManager appWidgetManager;
    ComponentName thisWidget;
    private ArrayList<UserAP> mList; 

    public MyTime(Context context, ArrayList<UserAP> list, AppWidgetManager appWidgetManager) {
        this.appWidgetManager = appWidgetManager;
        this.mList = list;
        remoteViews = new RemoteViews(context.getPackageName(), R.layout.sholatwidget);
        thisWidget = new ComponentName(context, HelloWidget.class);
    }

    public void run() {
        final UserAP listItem = mList.get(0); 
        remoteViews.setTextViewText(R.id.xyz,
                "" + **[I Want to Call listItem.getXYZ() Here from TimeKu.Java. How?]**);
        appWidgetManager.updateAppWidget(thisWidget, remoteViews);
    }

}
 }

On public void run() in HelloWidget.Java, i want to call/use listItem.getXYZ() from TimeKu.Java with same result. How?
Very great Thanks for your help.

Regards,

Widy.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T00:59:48+00:00Added an answer on May 24, 2026 at 12:59 am

    It’s generally a bad idea for one class to have access to members of another class without very good reason.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

everyone I got problem here I need to update a plist data in a
Everyone. I have a little issue with selecting value from the dropdown list. When
Everyone managing open-source-software runs into the problem, that with the time the process of
Everyone in my office uses Macs and therefore most use Safari. We have a
everyone, i have no idea why this doesn't work hopefully someone here can help
Hope everyone is doing well I am having a problem with make files in
Everyone use lot of List. I need to iterate over this list, so I
everyone. I have BMP specification from MS ( http://msdn.microsoft.com/en-us/library/dd183383.aspx ) and I want to
everyone the question is how to use options Show windows side by side by
everyone! Here is my question: How can I retrieve quantity of Employees? In DomainService

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.