Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

test: Reply
 
LinkBack Thread Tools
Old January 11th, 2013, 09:36 AM   #1 (permalink)
New Member
Thread Author (OP)
 
Join Date: Jan 2013
Posts: 1
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am developing some application for android and i have problem.

I push data with button click from another activity with intent to string of first activity, and i put from that string these data to listview by a adapter, and it is all ok, i mean i see on listview that data, but when i want to add new item in listview by click of button of second activity, i mean do again same thing, there is a problem: that data i push by a second button click replaces first button click data, and i want to add that data under first data in another listview row?

here is code of activity where is a listview:

package com.example.kupi;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import android.R.array;
import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;

public class popis_kupaca extends Activity {
public String ImeKupca;
public String PrezimeKupca;
public String OIBKupca;
public String AdresaKupca;

int i = 0;

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

ListView listView1 = (ListView) findViewById(R.id.listViewpopiskupaca);
listView1.setClickable(true);

ImeKupca = " ";
PrezimeKupca = " ";
OIBKupca = " ";
AdresaKupca = " ";

Intent intent = getIntent();
String[] values = intent.getStringArrayExtra("string-array");
String[] items = {ImeKupca + " " + PrezimeKupca + " " + OIBKupca + " " + AdresaKupca };

List<String> list = new ArrayList<String>();
ArrayList<String> arrayList = new ArrayList<String>(list);

if(values == null)
{
values = items;
}
else
{
ImeKupca = values[0];
PrezimeKupca = values[1];
OIBKupca = values[2];
AdresaKupca = values[3];

//items = new String[]{values[0] + " " + values[1] + " " + values[2] + " " + values[3] };
//items[i] = values[0] + " " + values[1] + " " + values[2] + " " + values[3];
items = new String[]{values[0] + " " + values[1] + " " + values[2] + " " + values[3], "danas"};

ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, items);
listView1.setAdapter(adapter);
}

//Dodaj Botun
Button pritisni4 = (Button) findViewById(R.id.dodaj1);
pritisni4.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent myIntent = new Intent(view.getContext(), unos_kupca.class);
startActivityForResult(myIntent, 0);
i++;
}
});

//Odustani Botun
Button pritisni5 = (Button) findViewById(R.id.odustani1);
pritisni5.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent myIntent = new Intent(view.getContext(), MainActivity.class);
startActivityForResult(myIntent, 0);
}
});
}
}

Advertisements
fighter123 is offline  
Last edited by Frisco; January 11th, 2013 at 09:49 AM. Reason: dupes merged and trimmed
Reply With Quote
sponsored links
Old January 11th, 2013, 09:47 AM   #2 (permalink)
Not Entitled
 
RichSz's Avatar
 
Join Date: Jul 2010
Location: Between Imladris and Lothlórien
Gender: Male
Posts: 2,088
 
Device(s): Nexus 5(u,r), N7.2-32(u,r), Nook Color, iPad2, Asus EEE Transformer w/ dock (stock)
Carrier: T-Mobile

Thanks: 1,639
Thanked 1,318 Times in 558 Posts
Default

Moved to Application Development.
__________________
Rich


Apple tells people what they want, Microsoft asks what people want, Google gives people what they want (for 15 minutes).


Site Rules, for your convenience
RichSz is offline  
Reply With Quote
Reply


Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 04:55 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.