Android Open Source - InfoWallpaper Pick Item Dialog






From Project

Back to project page InfoWallpaper.

License

The source code is released under:

MIT License

If you think the Android project InfoWallpaper listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.andreashedin.general;
/* ww  w. ja va  2s.c  om*/
import java.util.ArrayList;

import com.andreashedin.infowallpaper.DisplayValuePair;
import com.andreashedin.infowallpaper.R;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class PickItemDialog extends Dialog implements OnItemClickListener {
  
  public interface OnItemPickedListener {
    void itemPicked(int id, int flag);
  }
  
  private OnItemPickedListener mListener;
  private ArrayList<DisplayValuePair<Integer>> mItemList;
  private int mFlag;
  private ListView mList;
  
  public PickItemDialog(Context context, OnItemPickedListener listener, ArrayList<DisplayValuePair<Integer>> items, int flag) {
    super(context);
  
    mFlag = flag;
    mItemList = items;
    
    mListener = listener;
  }
  
  @Override
  public void onBackPressed() {
    cancel();
  }
  
  protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        setContentView(R.layout.pick_item); 
        
        mList = (ListView) findViewById(R.id.ListView01);
        mList.setOnItemClickListener(this);//.setOnItemSelectedListener(this);
        
        mList.setAdapter(new ArrayAdapter<DisplayValuePair<Integer>>(getContext(), R.layout.list_item, mItemList));
        
        setTitle(R.string.pickItemTitle);
  }

  @SuppressWarnings("unchecked")
  @Override
  public void onItemClick(AdapterView<?> adapterView, View view, int pos, long id) {
    Integer val = ((DisplayValuePair<Integer>)mList.getItemAtPosition(pos)).getValue();
    mListener.itemPicked(val.intValue(), mFlag);
    dismiss();
  }
}




Java Source Code List

com.andreashedin.general.ColorPickerDialog.java
com.andreashedin.general.CustomizeInfoDialog.java
com.andreashedin.general.EnterStringDialog.java
com.andreashedin.general.PickItemDialog.java
com.andreashedin.general.PositionInfosDialog.java
com.andreashedin.general.SelectConfigurationDialog.java
com.andreashedin.general.TextSizeDialog.java
com.andreashedin.general.WeatherSettingsDialog.java
com.andreashedin.infowallpaper.Background.java
com.andreashedin.infowallpaper.BatteryDataCollector.java
com.andreashedin.infowallpaper.ColorHandler.java
com.andreashedin.infowallpaper.ConfigHandler.java
com.andreashedin.infowallpaper.CurrentSongDataCollector.java
com.andreashedin.infowallpaper.DataCollector.java
com.andreashedin.infowallpaper.DateTimeDataCollector.java
com.andreashedin.infowallpaper.DisplayValuePair.java
com.andreashedin.infowallpaper.InfoData.java
com.andreashedin.infowallpaper.InfoItem.java
com.andreashedin.infowallpaper.LiveInfoSettings.java
com.andreashedin.infowallpaper.LiveInfoWallpaper.java
com.andreashedin.infowallpaper.PhoneStatusDataCollector.java
com.andreashedin.infowallpaper.Phone.java
com.andreashedin.infowallpaper.SaveLoadData.java
com.andreashedin.infowallpaper.Screen.java
com.andreashedin.infowallpaper.WeatherDataCollector.java
com.andreashedin.infowallpaper.WeatherHandler.java