1
我讀過一些問題有關this..i've嘗試他們建議所有的東西,但仍然,我有java的空指針.... 這裏是我的主要代碼ExpandableListView內彈出
public class DaftarAkun extends Activity {
TextView tekserror;
EditText password1;
EditText username;
EditText password2;
ImageButton buttonELVKelamin;
ImageButton buttonELVAktivitas;
// EditText email;
ExpandableListAdapter exListAdapterKelamin;
List<String> listDataHeaderKelamin;
HashMap<String, List<String>> listDataChildKelamin;
ExpandableListAdapter exListAdapterAktivitas;
List<String> listDataHeaderAktivitas;
HashMap<String, List<String>> listDataChildAktivitas;
Context thisContext = this;
protected void onCreate(Bundle savedInstance) {
super.onCreate(savedInstance);
setContentView(R.layout.daftar_akun);
buttonELVKelamin.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
ExpandableListView exListViewKelamin;
final Dialog dialog = new Dialog(thisContext);
dialog.setContentView(R.layout.pop_up_daftar_akun_elvkelamin);
dialog.setTitle("Jenis Kelamin");
LayoutInflater li = (LayoutInflater) getBaseContext()
.getSystemService(LAYOUT_INFLATER_SERVICE);
View popupKelamin = li.inflate(
R.layout.pop_up_daftar_akun_elvkelamin, null);
dialog.setContentView(v);
// get the listview
exListViewKelamin = (ExpandableListView) popupKelamin
.findViewById(R.id.exLVKelamin);
prepareListDataKelamin();
exListAdapterKelamin = new com.ta.helper.ExpandableListAdapter(
DaftarAkun.this, listDataHeaderKelamin,
listDataChildKelamin);
exListViewKelamin.setAdapter(exListAdapterKelamin);
exListViewKelamin
.setOnChildClickListener(new OnChildClickListener() {
@Override
public boolean onChildClick(
ExpandableListView parent, View v,
int groupPosition, int childPosition,
long id) {
// TODO Auto-generated method stub
return false;
}
});
WindowManager.LayoutParams params = dialog.getWindow()
.getAttributes();
params.gravity = Gravity.TOP | Gravity.LEFT;
params.y = 80;
dialog.getWindow().setAttributes(params);
// dialog width and height.
dialog.getWindow().setLayout(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
}
private void prepareListDataKelamin() {
listDataHeaderKelamin = new ArrayList<String>();
listDataChildKelamin = new HashMap<String, List<String>>();
// Adding child data
listDataHeaderKelamin.add("Jenis Kelamin");
// Adding child data
List<String> kelamin = new ArrayList<String>();
kelamin.add("Pria");
kelamin.add("Wanita");
listDataChildKelamin.put(listDataHeaderKelamin.get(0), kelamin);// Header,
// Child
// data
}
});
這裏是我的主要XML
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#99cc00"
android:scrollbarSize="1dp" >
<ImageButton
android:id="@+id/buttonLVKelamin"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="9dp"
android:layout_marginLeft="26.5dp"
android:layout_marginRight="25dp"
android:layout_marginTop="9dp"
android:background="#00000000"
android:src="@drawable/registrasi_hdpi_24" />
<ImageButton
android:id="@+id/buttonLVAktivitas"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp"
android:layout_marginLeft="26.5dp"
android:layout_marginRight="25dp"
android:layout_marginTop="9dp"
android:background="#00000000"
android:src="@drawable/registrasi_hdpi_24" />
</ScrollView>
,這裏是我的彈出式XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ExpandableListView
android:id="@+id/exLVKelamin"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</ExpandableListView>
</LinearLayout>
希望有人注意到我的F我會修復它
什麼是白癡我!謝謝soooo很多傢伙...:D – melandragem
發生在我們最好的:) – dharms
但嘿...我不想彈出..我點擊了按鈕,沒有任何反應 – melandragem