View difference between Paste ID: HMBgJXvZ and BF4PXywu
SHOW: | | - or go back to the newest paste.
1
package makemachine.android.examples;
2
3
4
import java.util.ArrayList;
5
6
import android.app.Dialog;
7
import android.content.Context;
8
import android.util.Log;
9
import android.view.View;
10
import android.view.View.OnClickListener;
11
import android.view.Window;
12
import android.widget.AdapterView;
13
import android.widget.ArrayAdapter;
14
import android.widget.Button;
15
import android.widget.ListView;
16
import android.widget.AdapterView.OnItemClickListener;
17
18
/** Class Must extends with Dialog */
19
/** Implement onClickListener to dismiss dialog when OK Button is pressed */
20
public class Test extends Dialog implements OnClickListener, OnItemClickListener {
21
	String selected_value;
22
	Button okButton;
23
	ArrayList<String> site=new ArrayList<String>();
24
	String[] sitestr;
25
	String hi[];
26
//	ListView list_view;
27
28
	public Test(Context context,String[] value) {
29
		super(context);
30
		hi=value;
31
		Log.v("Length",""+hi.length);
32
		/** 'Window.FEATURE_NO_TITLE' - Used to hide the title */
33
		requestWindowFeature(Window.FEATURE_NO_TITLE);
34
		/** Design the dialog in main.xml file */
35
		setContentView(R.layout.test);
36
		
37
		ListView lst=(ListView)findViewById(R.id.list_view);
38
		
39
	
40
41
		 //ArrayAdapter<String> adapter = new ArrayAdapter<String>(getContext(), android.R.layout.simple_list_item_1,value);
42
		
43
			
44
45
		 lst.setAdapter(new ArrayAdapter(this.getContext(),android.R.layout.simple_list_item_1, hi));
46
		 lst.setOnItemClickListener(this);
47
48
//		okButton = (Button) findViewById(R.id.cancel);
49
//		okButton.setOnClickListener(this);
50
	}
51
52
	@Override
53
	public void onClick(View v) {
54
		/** When OK Button is clicked, dismiss the dialog */
55
		if (v == okButton)
56
			dismiss();
57
	}
58
59
	@Override
60
	public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
61
		// TODO Auto-generated method stub
62
		selected_value=hi[arg2];
63
		Log.v("selected_value", selected_value);
64
	}
65
66
}