Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package makemachine.android.examples;
- import java.util.ArrayList;
- import android.app.Dialog;
- import android.content.Context;
- import android.util.Log;
- import android.view.View;
- import android.view.View.OnClickListener;
- import android.view.Window;
- import android.widget.AdapterView;
- import android.widget.ArrayAdapter;
- import android.widget.Button;
- import android.widget.ListView;
- import android.widget.AdapterView.OnItemClickListener;
- /** Class Must extends with Dialog */
- /** Implement onClickListener to dismiss dialog when OK Button is pressed */
- public class Test extends Dialog implements OnClickListener, OnItemClickListener {
- String selected_value;
- Button okButton;
- ArrayList<String> site=new ArrayList<String>();
- String[] sitestr;
- String hi[];
- // ListView list_view;
- public Test(Context context,String[] value) {
- super(context);
- hi=value;
- Log.v("Length",""+hi.length);
- /** 'Window.FEATURE_NO_TITLE' - Used to hide the title */
- requestWindowFeature(Window.FEATURE_NO_TITLE);
- /** Design the dialog in main.xml file */
- setContentView(R.layout.test);
- ListView lst=(ListView)findViewById(R.id.list_view);
- //ArrayAdapter<String> adapter = new ArrayAdapter<String>(getContext(), android.R.layout.simple_list_item_1,value);
- lst.setAdapter(new ArrayAdapter(this.getContext(),android.R.layout.simple_list_item_1, hi));
- lst.setOnItemClickListener(this);
- // okButton = (Button) findViewById(R.id.cancel);
- // okButton.setOnClickListener(this);
- }
- @Override
- public void onClick(View v) {
- /** When OK Button is clicked, dismiss the dialog */
- if (v == okButton)
- dismiss();
- }
- @Override
- public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
- // TODO Auto-generated method stub
- selected_value=hi[arg2];
- Log.v("selected_value", selected_value);
- }
- }
Add Comment
Please, Sign In to add comment