Go Back   Android Forums > Android Discussion > Android Applications
Android Applications All the information you could ever want about Android Applications. Learn about apps and get help with them... all here! New apps can be found and announced in the Applications Announcements forum linked below.

Get excited for the Samsung Galaxy S5! Find everything you need and discuss it in our Galaxy S5 Forum!

test: Reply
 
LinkBack Thread Tools
Old June 9th, 2013, 08:39 AM   #1 (permalink)
New Member
Thread Author (OP)
 
Join Date: Jun 2013
Posts: 2
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default Update ListView from OnItemClickListener of GridView from TabContenFactory class

I am new to android (with C# background) and trying to develop my first big application.

I have a TableView at top and inside my table view I have a Tab view on left and a ListView on right. My Tab view contains Gridview which contains ImageView with Text belowImage.

Now what I want to do is, first somehow I want to link each gridview item with a special code. So my quest is what is the best way to do this,
1. Keep a two dimensional array or dictionary (if exist) to find code for each item of gridview
2. Somehow Add this code with each item when adding items into girdview (this should not be display on the screen). e.g with some hidden property. Please suggest how.


Second thing I want to do is, whenever user clicks on any item in gridview, name of the item and associated code should be added into the listview. The way I have done this by accessing listview in onItemClickListener event on grid as shown in code below.
Is this the good way to do this or is there any other better way? Please suggest.

Here java class of main activity
[HIGH]
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.myactivity );


List<String> items = new ArrayList<String>();
items.add("First");
items.add("second");
items.add("thired");
ListView lv = (ListView) findViewById(R.id.listView1);
lv.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_ list_item_1,items));

TabHost tabHost = (TabHost)findViewById(R.id.mytabhost);
tabHost.setup();
for(int i=1;i<=3;i++)
{

TabSpec spec = tabHost.newTabSpec("tag"+i);
spec.setIndicator("Tab"+i);
spec.setContent(new TabHost.TabContentFactory() {

@Override
public View createTabContent(String arg0) {
final String[] sa = new String[25];
GridView gv = new GridView(MainActivity.this);
gv.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParam s.WRAP_CONTENT) );
Resources r = Resources.getSystem();
int px =(int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_ DIP, 100, r.getDisplayMetrics());
gv.setColumnWidth(px);
gv.setGravity(Gravity.LEFT);
gv.setNumColumns(GridView.AUTO_FIT);
gv.setStretchMode(GridView.STRETCH_SPACING_UNIFORM );
px =(int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_ DIP, 10, r.getDisplayMetrics());
gv.setHorizontalSpacing(px);
gv.setVerticalSpacing(px);
gv.setPadding(0, px, px, px);
for(int j=0;j<25;j++)
{
sa[j]=arg0+j;
}


GridAdapter ga = new GridAdapter(MainActivity.this,25);

gv.setAdapter(ga);;


gv.setOnItemClickListener(new OnItemClickListener(){

public void onItemClick(AdapterView<?> parent, View arg1,
int position, long arg3) {

ArrayAdapter aad = (ArrayAdapter)((ListView)MainActivity.this.findVie wById(R.id.listView1)).getAdapter();
aad.add("New Ite");
Toast.makeText(MainActivity.this, "Clicked GV " , Toast.LENGTH_SHORT).show();
}


});
return gv;
}
});
tabHost.addTab(spec);
}

}
[/HIGH]

tempdatasave is offline  
Reply With Quote
sponsored links
Old June 11th, 2013, 04:07 AM   #2 (permalink)
New Member
Thread Author (OP)
 
Join Date: Jun 2013
Posts: 2
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default Please help

Any suggestion?
tempdatasave is offline  
Reply With Quote
Reply
Tags
update listview from gridview


Go Back   Android Forums > Android Discussion > Android Applications
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 11:43 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.