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

  • Home
  • SEARCH
  • 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 7308613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T23:34:53+00:00 2026-05-28T23:34:53+00:00

I used the below code for displaying all cities time . When i execute

  • 0

I used the below code for displaying all cities time. When i execute my code the time will displayed in a list view, now my problem is once i click any one of the country (position in list), i must pass the Country name, day, month, year and time from the list to another class (*ShowAnalogClock)*. In ShowAnalogClock class i will display the time which is fetched from the list view.

main.xml

<?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" >

    <AutoCompleteTextView
        android:id="@+id/autoCompleteZone"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:completionThreshold="1" >

        <requestFocus />
    </AutoCompleteTextView>

    <ListView
        android:id="@+id/zoneList"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >
    </ListView>

    <TextView
        android:id="@+id/autoCompleteTextview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Medium Text"
        android:textAppearance="?android:attr/textAppearanceMedium" />

</LinearLayout>

timezone.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="?android:attr/listPreferredItemHeight"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/timezone_name"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:textSize="25dip" />

    <TextView
        android:id="@+id/timezone_time"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:textSize="15dip" />

</LinearLayout>

My Java code is,

TimeZoneProjectActivity.java

package com.test.timezone;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class TimeZoneProjectActivity extends Activity {
    /** Called when the activity is first created. */
    ListView ZONE_LIST;
    AutoCompleteTextView zoneComplete_TXT;
    TimeZoneAdaptor timezoneAdaptor;
    List<TimeZoneDataList> timezonelist;
    String[] listItems;
    TextView auto_completeTXT;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        auto_completeTXT = (TextView) findViewById(R.id.autoCompleteTextview);
        ZONE_LIST = (ListView) findViewById(R.id.zoneList);
        zoneComplete_TXT = (AutoCompleteTextView) findViewById(R.id.autoCompleteZone);
        timezonelist = new ArrayList<TimeZoneDataList>();
        timezoneAdaptor = new TimeZoneAdaptor(this, R.layout.timezoneview,
                timezonelist);

        ZONE_LIST.setAdapter(timezoneAdaptor);

        ZONE_LIST.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View v,
                    int position, long arg3) {
                // TODO Auto-generated method stub
                //

                System.out.println("Clicked Position" + position);
            }
        });
    }

    @Override
    protected void onStart() {
        super.onStart();

        listItems = TimeZone.getAvailableIDs();
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                android.R.layout.simple_dropdown_item_1line, listItems);
        zoneComplete_TXT.setAdapter(adapter);

        TimeZone timezone = null;
        SimpleDateFormat format = new SimpleDateFormat(
                "EEE, MMM d, yyyy h:mm a");
        Date now = new Date();

        for (int index = 0; index < listItems.length; ++index) {
            timezone = TimeZone.getTimeZone(listItems[index]);

            format.setTimeZone(timezone);

            timezonelist.add(new TimeZoneDataList(
                    getDiaplayName(listItems[index]), format.format(now)));

            timezone = null;
        }
    }

    private String getDiaplayName(String timezonename) {
        String displayname = timezonename;
        int sep = timezonename.indexOf('/');

        if (-1 != sep) {
            displayname = timezonename.substring(0, sep) + ", "
                    + timezonename.substring(sep + 1);
            displayname = displayname.replace("_", " ");
        }

        return displayname;
    }

    public class TimeZoneAdaptor extends ArrayAdapter<TimeZoneDataList> {

        List<TimeZoneDataList> objects = null;

        public TimeZoneAdaptor(Context context, int textViewResourceId,
                List<TimeZoneDataList> objects) {
            super(context, textViewResourceId, objects);

            this.objects = objects;
        }

        @Override
        public int getCount() {
            return ((null != objects) ? objects.size() : 0);
        }

        @Override
        public TimeZoneDataList getItem(int position) {
            return ((null != objects) ? objects.get(position) : null);
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View view = convertView;

            if (null == view) {
                LayoutInflater vi = (LayoutInflater) TimeZoneProjectActivity.this
                        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                view = vi.inflate(R.layout.timezoneview, null);
            }

            TimeZoneDataList data = objects.get(position);

            if (null != data) {
                TextView textName = (TextView) view
                        .findViewById(R.id.timezone_name);
                TextView textTime = (TextView) view
                        .findViewById(R.id.timezone_time);

                textName.setText(data.name);
                textTime.setText(data.time);
            }

            return view;
        }
    }
}

TimeZoneDataList.java

package com.test.timezone;

public class TimeZoneDataList {
    public String name;
    public String time;

    public TimeZoneDataList(String name, String time) {
        this.name = name;
        this.time = time;
    }
}

In which code i will add in the following block, to pass the listview content

ZONE_LIST.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View v,
                    int position, long arg3) {
                // TODO Auto-generated method stub

                System.out.println("Clicked Position" + position);
            }
        });
  • 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-28T23:34:54+00:00Added an answer on May 28, 2026 at 11:34 pm

    You can only pass primitives and Parcelable objects between Activities. It should be pretty easy to make a class which encapsulates your primitives and implements the Parcelable interface. You can then pass this class in the Extras bundle of the Intent.

    Or you can just pass your primitives directly, also in the Intent Extras.

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

Sidebar

Related Questions

I have some problem with my cfml website. I have used the below code
I am having a very specific problem in JQuery The code below is used
i used all the examples and source code out there for displaying application content
I have used below code for displaying multiple marker in the google map and
Using the code below I am displaying pop up windows. I used the toggle()
I used below code for free hand drawing on the whole view: UIGraphicsBeginImageContext(self.view.frame.size); [drawImage.image
I had used the below code to get the row index of the UIPickerView
My below code works fine and is used to populate a <select> item with
I used the code below to compress files and they keep growing instead of
The code below shows a sample that I've used recently to explain the different

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.