[Java for Android App Development] rony dcosta:
dear all,

Greetings from Rony.

this is my first Query as i newly joined this forum. & quite impressed by the great work being done here, and quite intelligent and experienced persons here about everything in Android.

I am working with Eclipse & my 2 queries are as follows.

1 > how to display the selected value of listview in the textview as shown in "pix 1" ( attached)

i am attaching an image "pix 1" , a drawing representation what exactly i want to ask.

i am adding my code too for the reference.

---------------------------------------------------------------------------------

2> how to open a new tabpager when the confirm button is click? as shown in "pix 2" (attached)

i am putting here my same code for the reference.

---------------------------------------------------------------------------------

please some one can figure out where i am going wrong about my code or any method i have adopted wrong.

Thanks in advance..

-Rony

------------------------------------------

FOLLOWING IS MY CODE

------------------------------------------

// This is my ListView Fragment

package com.example.tabs;

import java.io.FileOutputStream;

import java.io.IOException;

import java.io.OutputStreamWriter;

import java.util.ArrayList;

import java.util.Arrays;

import com.example.tabs.R.color;

import android.app.Fragment;

import android.content.Context;

import android.os.Bundle;

import android.view.LayoutInflater;

import android.view.Menu;

import android.view.MenuInflater;

import android.view.MenuItem;

import android.view.View;

import android.view.ViewGroup;

import android.widget.AdapterView;

import android.widget.ArrayAdapter;

import android.widget.Button;

import android.widget.ListView;

import android.widget.AdapterView.OnItemClickListener;

public class ShopFragment extends Fragment implements View.OnClickListener{

//private int mActivatedPosition = ListView.INVALID_POSITION;

ListView LV;

ArrayList<String> arraylist;

Button confirm;

private String[] Shops = new String [] {

"A shop",

"B shop",

"C shop",

"D shop",

"E shop",

"M shop",

"N shop",

"O shop",

"P shop",

"Q shop",

"R shop",

"S shop",

"T shop",

"U shop",

"V shop",

"W shop",

"X shop",

"Y shop",

"S shop",

"F shop",

"G shop",

"H shop",

"I shop",

"Z shop",

"K shop",

"L shop"

};

[MENTION=439709]override[/MENTION]

public View onCreateView(LayoutInflater inflater, ViewGroup container,

Bundle savedInstanceState) {

setHasOptionsMenu(false);

View rootView = inflater.inflate(R.layout.listview_fragment, container, false);

LV = (ListView)rootView.findViewById(R.id.listView1);

LV.setFocusableInTouchMode(true);

LV.setChoiceMode(ListView.CHOICE_MODE_SINGLE);

//LV.setSelection(1);

ArrayAdapter<String> adapter;

arraylist = new ArrayList<String>();

for(int i=0;i<Shops.length;i++){

arraylist.add(Shops);

Arrays.sort(Shops);

}

adapter = new ArrayAdapter<String>(getActivity(),

android.R.layout.simple_list_item_activated_1,

android.R.id.text1, Shops);

LV.setFastScrollEnabled(true);

LV.setAdapter(adapter);

LV.setOnItemClickListener(new OnItemClickListener() {

[MENTION=439709]override[/MENTION]

public void onItemClick(AdapterView<?> arg0, View arg1, int position,

long arg3) {

LV.setItemChecked(position, true);

setHasOptionsMenu(true);

}

});

return rootView;

}

[MENTION=439709]override[/MENTION]

public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {

inflater.inflate(R.menu.activity_next, menu);

super.onCreateOptionsMenu(menu,inflater);

// MenuItem item = menu.findItem(R.id.next);

//item.setVisible(false);

}

[MENTION=439709]override[/MENTION]

public boolean onOptionsItemSelected(MenuItem item) {

switch (item.getItemId()) {

case R.id.next:

// confirm action

Confirm();

return true;

default:

return super.onOptionsItemSelected(item);

}

}

/**

* Launching new activity

* */

private void Confirm() {

setHasOptionsMenu(true);

}

[MENTION=439709]override[/MENTION]

public void onClick(View v) {

// TODO Auto-generated method stub

}

}

/////////////////////////////////////////

this is the second fragment where the selected listview item to be called

package com.example.tabs;

import java.io.BufferedReader;

import java.io.ByteArrayInputStream;

import java.io.ByteArrayOutputStream;

import java.io.DataInputStream;

import java.io.File;

import java.io.FileInputStream;

import java.io.FileOutputStream;

import java.io.IOException;

import java.io.InputStreamReader;

import android.app.Activity;

import android.app.AlertDialog;

import android.app.Fragment;

import android.app.FragmentManager;

import android.app.FragmentTransaction;

import android.content.Context;

import android.content.ContextWrapper;

import android.content.DialogInterface;

import android.content.Intent;

import android.graphics.Bitmap;

import android.graphics.BitmapFactory;

import android.graphics.Color;

import android.os.Bundle;

import android.provider.MediaStore;

import android.util.Log;

import android.view.Gravity;

import android.view.LayoutInflater;

import android.view.Menu;

import android.view.MenuInflater;

import android.view.MenuItem;

import android.view.View;

import android.view.ViewGroup;

import android.view.View.OnClickListener;

import android.widget.Button;

import android.widget.ImageView;

import android.widget.TextView;

import android.widget.Toast;

public class ListFragment extends Fragment {

private TextView txt1;

[MENTION=439709]override[/MENTION]

public View onCreateView(LayoutInflater inflater, ViewGroup container,

Bundle savedInstanceState) {

View rootView = inflater.inflate(R.layout.list_fragment, container, false);

setHasOptionsMenu(true);

txt1 = (TextView)rootView.findViewById(R.id.textView1);

return rootView;

}

}