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 9147817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:05:02+00:00 2026-06-17T11:05:02+00:00

Following my privious qustion that you can see here: How to create custom listview

  • 0

Following my privious qustion that you can see here:

How to create custom listview for android with margins between 2 elements?

I have made some progress due to the help I recived here.
So my state right now is:

https://i.stack.imgur.com/yK5to.jpg

pressing on the blue part of one of the tasks pops the following color plate activity:

https://i.stack.imgur.com/UWmIg.jpg

all the 5 colors here are buttons, what i need to do is to check what color was
pressed and then change the background drawing of the task that opened the color plate activity.

Only that i don’t understand how it’s done, any suggestions?
in the color plate activity i have an “setOnClickListener” function for each one of the buttons.

here is the java code for my list activity:

public class SkyGiraffeAppActivity extends Activity implements AdapterView.OnItemClickListener, View.OnClickListener {
// All static variables
static final String TAG = "SkyGiraffeAppActivity";
// XML node keys
static final String KEY_TASK = "task"; // parent node
static final String KEY_ID = "id";
static final String KEY_TITLE = "title";
static final String KEY_DATE = "date";
static final String KEY_TIME = "time";
static final String KEY_PRIORITY  = "priority";

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ListView list = new ListView(this);
    list.setDivider(null);
    list.setDividerHeight(0);
    setContentView(list);

    final ArrayList<HashMap<String, String>> menuItems = new ArrayList<HashMap<String, String>>();
    Log.e(TAG, "Created Array");

    XMLParser parser = new XMLParser();

    Log.e(TAG, "Getting xml from raw folder");
    InputStream xml = getResources().openRawResource(R.raw.taskslists); // getting XML

    Log.e(TAG, "reading xml file to string");
    String sxml = parser.readTextFile(xml);

    Log.e(TAG, "creating dom element from string");
    Document doc = parser.getDomElement(sxml); // getting DOM element

    Log.e(TAG, "getting node list of all the elements");
    NodeList nodeList = doc.getElementsByTagName(KEY_TASK);

    Log.e(TAG, "looping through all the elements");
    for (int i = 0; i < nodeList.getLength(); i++) 
    {
        // creating new HashMap
        HashMap<String, String> map = new HashMap<String, String>();
        Element e = (Element) nodeList.item(i);
        Log.e(TAG, "element number: " + i + " added to hash map");
        // adding each child node to HashMap key => value
        map.put(KEY_ID, parser.getValue(e, KEY_ID));
        map.put(KEY_TITLE, parser.getValue(e, KEY_TITLE));
        map.put(KEY_DATE, parser.getValue(e, KEY_DATE));
        map.put(KEY_TIME, parser.getValue(e, KEY_TIME));
        map.put(KEY_PRIORITY, parser.getValue(e, KEY_PRIORITY));

        // adding HashList to ArrayList
        menuItems.add(map);
    }

    // Adding menuItems to ListView
    ListAdapter adapter = new SimpleAdapter(this, menuItems, R.layout.row,
          new String[] { KEY_TITLE, KEY_DATE, KEY_TIME, KEY_PRIORITY}, 
          new int[]    { R.id.text_title, R.id.text_date, R.id.text_time ,R.id.image_priority}){

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View row =  super.getView(position, convertView, parent);
            View left = row.findViewById(R.id.bchangecolor);
            left.setTag(position);
            left.setOnClickListener(SkyGiraffeAppActivity.this);
            View right = row.findViewById(R.id.barrow);
            right.setTag(position);
            right.setOnClickListener(SkyGiraffeAppActivity.this);

            ImageView prioriy = (ImageView) row.findViewById(R.id.image_priority);


            Log.e(TAG, "pririty number: " + menuItems.get(position).get(KEY_PRIORITY));
            int number = Integer.valueOf(menuItems.get(position).get(KEY_PRIORITY));
            switch ( number )
            {
            case 1:
                prioriy.setImageResource(R.drawable.priority_first);
                break;
            case 2:
                prioriy.setImageResource(R.drawable.priority_second);
                break;
            case 3:
                prioriy.setImageResource(R.drawable.priority_third);
                break;
            case 4:
                prioriy.setImageResource(R.drawable.priority_fourth);
                break;
            case 5:
                prioriy.setImageResource(R.drawable.priority_fifth);
                break;
            default:
                prioriy.setImageResource(R.drawable.priority_first);
            }

            return row;
        }
    };

    list.setAdapter(adapter);
    list.setOnItemClickListener(this);  
}

public void onClick(View v) {
     switch(v.getId()) {
        case R.id.bchangecolor:
            Log.e(TAG, "pressed the color change button on" + v.getId());
            startActivity(new Intent(getApplicationContext(),TaskColorChangeActivity.class));
            break;
        case R.id.barrow:
            Log.e(TAG, "pressed the arrow button on" + v.getId());
            Intent intent = createIntentwithExtra(v);
            startActivity(intent);
            break;
        default:
            break;
        }   
}

public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
    Log.e(TAG, "pressed the row itself" + v.getId());
    Intent intent = createIntentwithExtra(v);
    startActivity(intent);  
}

public Intent createIntentwithExtra(View v)
{
    Intent intent = new Intent(getApplicationContext(), SingleMenuItemActivity.class);
    String title = ((TextView) v.findViewById(R.id.text_title)).getText().toString();
    String date = ((TextView) v.findViewById(R.id.text_date)).getText().toString();
    String time = ((TextView) v.findViewById(R.id.text_time)).getText().toString();
    intent.putExtra(KEY_TITLE, title);
    intent.putExtra(KEY_DATE, date);
    intent.putExtra(KEY_TIME, time);

    return intent;
}}

and my color plate activity:

public class TaskColorChangeActivity extends Activity 
{
static final String TAG = "TaskColorChangeActivity";    
Button bBlue, bGreen, bYellow, bOrange, bRed;

protected void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.colorplate);

    bBlue = (Button) findViewById(R.id.bblue);
    bGreen = (Button) findViewById(R.id.bgreen);
    bYellow = (Button) findViewById(R.id.byellow);
    bOrange = (Button) findViewById(R.id.borange);
    bRed = (Button) findViewById(R.id.bred);

    bBlue.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {   
        }
    });
    bGreen.setOnClickListener(new View.OnClickListener() {  
        public void onClick(View v) {   
        }
    });
    bYellow.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {   
        }
    });
    bOrange.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        }
    });
    bRed.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        }
    });
}}

it would be nice if someone with permissions changed the links to the actual images.
Thanks.

  • 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-06-17T11:05:03+00:00Added an answer on June 17, 2026 at 11:05 am

    You can return some data from you activity to your parent activity

    ( How to return a result (startActivityForResult) from a TabHost Activity? )

    You can return what color you’ve choosen and regarding this data you can do whatever you want.

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

Sidebar

Related Questions

Following my previous question , I need to create a value consisting of a
Related to my previous question , I have a string on the following format:
I have a problem following from my previous problem . I also have the
Following on from my previous question I have found the culprit in my code
Following up on my previous newbie question about Paypal , I have a new
After my previous question , I have an SQL query like the following: SELECT
I have the following markup: <ul> <li><a href=#>first</a></li> <li><a href=#>largerWord</a></li> <li class=active><a href=#>third</a></li> </ul>
Here's a bit of a newbie Python question about instance variables. Consider the following
I have the following code, necessary to track an embedded Youtube video in my
I have asked a similar question before here , but after much thought, and

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.