Java Code Examples for android.widget.ExpandableListView#setOnChildClickListener()

The following examples show how to use android.widget.ExpandableListView#setOnChildClickListener() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
		Bundle savedInstanceState) {
	View view = inflater.inflate(R.layout.channel_list, container, false);
	
	OnChildClickListener channelItemListener = new OnChildClickListener() {
		@Override
		public boolean onChildClick(ExpandableListView parent, View v,
				int groupPosition, int childPosition, long id) {
			JSONObject channelItem = (JSONObject) adapter.getChild(groupPosition, childPosition);
			channelSelected(channelItem);
			return true;
		}
	};
	
	ExpandableListView channelsView = (ExpandableListView) view.findViewById(R.id.channelListView);
	channelsView.setEmptyView(view.findViewById(R.id.channelListProgress));
	channelsView.setAdapter(adapter);
	channelsView.setOnChildClickListener(channelItemListener);
	
	PauseOnScrollListener listener = new PauseOnScrollListener(ImageLoader.getInstance(), true, true);
	channelsView.setOnScrollListener(listener);
	expandAll(view);
	
	return view;
}
 
Example 2
/**
 * Updates the screen state (current list and other views) when the
 * content changes.
 * 
 * @see Activity#onContentChanged()
 */
@Override
public void onContentChanged() {
    super.onContentChanged();
    View emptyView = findViewById(com.android.internal.R.id.empty);
    mList = (ExpandableListView)findViewById(com.android.internal.R.id.list);
    if (mList == null) {
        throw new RuntimeException(
                "Your content must have a ExpandableListView whose id attribute is " +
                "'android.R.id.list'");
    }
    if (emptyView != null) {
        mList.setEmptyView(emptyView);
    }
    mList.setOnChildClickListener(this);
    mList.setOnGroupExpandListener(this);
    mList.setOnGroupCollapseListener(this);
    
    if (mFinishedStart) {
        setListAdapter(mAdapter);
    }
    mFinishedStart = true;
}
 
Example 3
Source Project: delion   File: RecentTabsPage.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Constructor returns an instance of RecentTabsPage.
 *
 * @param activity The activity this view belongs to.
 * @param recentTabsManager The RecentTabsManager which provides the model data.
 */
public RecentTabsPage(Activity activity, RecentTabsManager recentTabsManager) {
    mActivity = activity;
    mRecentTabsManager = recentTabsManager;

    mTitle = activity.getResources().getString(R.string.recent_tabs);
    mThemeColor = ApiCompatibilityUtils.getColor(
            activity.getResources(), R.color.default_primary_color);
    mRecentTabsManager.setUpdatedCallback(this);
    LayoutInflater inflater = LayoutInflater.from(activity);
    mView = (ViewGroup) inflater.inflate(R.layout.recent_tabs_page, null);
    mListView = (ExpandableListView) mView.findViewById(R.id.odp_listview);
    mAdapter = buildAdapter(activity, recentTabsManager);
    mListView.setAdapter(mAdapter);
    mListView.setOnChildClickListener(this);
    mListView.setGroupIndicator(null);
    mListView.setOnGroupCollapseListener(this);
    mListView.setOnGroupExpandListener(this);
    mListView.setOnCreateContextMenuListener(this);

    mView.addOnAttachStateChangeListener(this);
    ApplicationStatus.registerStateListenerForActivity(this, activity);
    // {@link #mInForeground} will be updated once the view is attached to the window.

    onUpdated();
}
 
Example 4
Source Project: AndroidChromium   File: RecentTabsPage.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Constructor returns an instance of RecentTabsPage.
 *
 * @param activity The activity this view belongs to.
 * @param recentTabsManager The RecentTabsManager which provides the model data.
 */
public RecentTabsPage(Activity activity, RecentTabsManager recentTabsManager) {
    mActivity = activity;
    mRecentTabsManager = recentTabsManager;

    mTitle = activity.getResources().getString(R.string.recent_tabs);
    mThemeColor = ApiCompatibilityUtils.getColor(
            activity.getResources(), R.color.default_primary_color);
    mRecentTabsManager.setUpdatedCallback(this);
    LayoutInflater inflater = LayoutInflater.from(activity);
    mView = (ViewGroup) inflater.inflate(R.layout.recent_tabs_page, null);
    mListView = (ExpandableListView) mView.findViewById(R.id.odp_listview);
    mAdapter = buildAdapter(activity, recentTabsManager);
    mListView.setAdapter(mAdapter);
    mListView.setOnChildClickListener(this);
    mListView.setGroupIndicator(null);
    mListView.setOnGroupCollapseListener(this);
    mListView.setOnGroupExpandListener(this);
    mListView.setOnCreateContextMenuListener(this);

    mView.addOnAttachStateChangeListener(this);
    ApplicationStatus.registerStateListenerForActivity(this, activity);
    // {@link #mInForeground} will be updated once the view is attached to the window.

    onUpdated();
}
 
Example 5
Source Project: AnyTime   File: DoingListFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
		Bundle savedInstanceState) {
	View rootView = inflater.inflate(R.layout.fragment_main_doing_list,
			container, false);
	mDoingListData = new ArrayList<DoingListData>();
	expandableListView = (ExpandableListView) rootView
			.findViewById(R.id.expandableListView_doing_list);
	adapter = new AnytimeExpandableListAdapter(activity);
	expandableListView.setAdapter(adapter);
	expandableListView.setOnChildClickListener(listener);
	messageText = (TextView) rootView
			.findViewById(R.id.textView_loading_wait);
	LoadingData();
	return rootView;
}
 
Example 6
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.gatt_services_characteristics);

    final Intent intent = getIntent();
    mDeviceName = intent.getStringExtra(EXTRAS_DEVICE_NAME);
    mDeviceAddress = intent.getStringExtra(EXTRAS_DEVICE_ADDRESS);

    // Sets up UI references.
    ((TextView) findViewById(R.id.device_address)).setText(mDeviceAddress);
    mGattServicesList = (ExpandableListView) findViewById(R.id.gatt_services_list);
    mGattServicesList.setOnChildClickListener(servicesListClickListner);
    mConnectionState = (TextView) findViewById(R.id.connection_state);
    mDataField = (TextView) findViewById(R.id.data_value);

    getActionBar().setTitle(mDeviceName);
    getActionBar().setDisplayHomeAsUpEnabled(true);
    Intent gattServiceIntent = new Intent(this, BluetoothLeService.class);
    bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE);
}
 
Example 7
Source Project: Android   File: MainActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
			
	mlistView = new ExpandableListView(this);                        
       mlistView.setOnGroupClickListener(this);        
       mlistView.setOnChildClickListener(this);
       
       List<GroupList> groups = new ArrayList<GroupList>();
       for( int i=0; i<mParentMenu.length; i++) {        	
       	List<GroupList> childs = new ArrayList<GroupList>();
       	for( int j=0; j<mChildMenu[i].length; j++ ) {
       		childs.add(new GroupListChild(mChildMenu[i][j]));
       	}
       	groups.add(new GroupListParent(mParentMenu[i],childs));
       }

       mAdapter = new GroupListAdapter(this,groups);
       mlistView.setAdapter(mAdapter);
       
       setContentView(mlistView);		
}
 
Example 8
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.gatt_services_characteristics);

	final Intent intent = getIntent();
	mDeviceName = intent.getStringExtra(EXTRAS_DEVICE_NAME);
	mDeviceAddress = intent.getStringExtra(EXTRAS_DEVICE_ADDRESS);

	// Sets up UI references.
	((TextView) findViewById(R.id.device_address)).setText(mDeviceAddress);
	mGattServicesList = (ExpandableListView) findViewById(R.id.gatt_services_list);
	mGattServicesList.setOnChildClickListener(servicesListClickListner);
	mConnectionState = (TextView) findViewById(R.id.connection_state);

	getActionBar().setTitle(mDeviceName);
	getActionBar().setDisplayHomeAsUpEnabled(true);
	BleApplication app = (BleApplication) getApplication();
	mBle = app.getIBle();
}
 
Example 9
Source Project: jessica   File: DeviceControlActivity.java    License: MIT License 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.gatt_services_characteristics);

    final Intent intent = getIntent();
    mDeviceName = intent.getStringExtra(EXTRAS_DEVICE_NAME);
    mDeviceAddress = intent.getStringExtra(EXTRAS_DEVICE_ADDRESS);

    // Sets up UI references.
    ((TextView) findViewById(R.id.device_address)).setText(mDeviceAddress);
    mGattServicesList = (ExpandableListView) findViewById(R.id.gatt_services_list);
    mGattServicesList.setOnChildClickListener(servicesListClickListner);
    mConnectionState = (TextView) findViewById(R.id.connection_state);
    mDataField = (TextView) findViewById(R.id.data_value);

    getActionBar().setTitle(mDeviceName);
    getActionBar().setDisplayHomeAsUpEnabled(true);
    Intent gattServiceIntent = new Intent(this, BluetoothLeService.class);
    bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE);
}
 
Example 10
@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.gatt_services_characteristics);
        System.out.println("DeviceControlActivity onCreate");
        final Intent intent = getIntent();
        mDeviceName = intent.getStringExtra(EXTRAS_DEVICE_NAME);
        mDeviceAddress = intent.getStringExtra(EXTRAS_DEVICE_ADDRESS);

        // Sets up UI references.
        ((TextView) findViewById(R.id.device_address)).setText(mDeviceAddress);
        mGattServicesList = (ExpandableListView) findViewById(R.id.gatt_services_list);
        mGattServicesList.setOnChildClickListener(servicesListClickListner);
        mConnectionState = (TextView) findViewById(R.id.connection_state);
        mDataField = (TextView) findViewById(R.id.data_value);

//        getActionBar().setTitle(mDeviceName);
//        getActionBar().setDisplayHomeAsUpEnabled(true);
        Intent gattServiceIntent = new Intent(this, BluetoothLeService.class);
        bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE);
    }
 
Example 11
Source Project: FireFiles   File: RootsFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(
        LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    final View view = inflater.inflate(R.layout.fragment_roots, container, false);
    mList = (ExpandableListView) view.findViewById(android.R.id.list);
    mList.setOnChildClickListener(mItemListener);
    mList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);

    DisplayMetrics metrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
    int width = Utils.dpToPx(302);

    boolean rtl = Utils.isRTL();
    int leftPadding = rtl ? 10 : 50;
    int rightPadding = rtl ? 50 : 10;
    int leftWidth = width - Utils.dpToPx(leftPadding);
    int rightWidth = width - Utils.dpToPx(rightPadding);

    if(Utils.hasJellyBeanMR2()){
        mList.setIndicatorBoundsRelative(leftWidth, rightWidth);

    } else {
        mList.setIndicatorBounds(leftWidth, rightWidth);
    }
    return view;
}
 
Example 12
Source Project: FireFiles   File: RootsFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(
        LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    final View view = inflater.inflate(R.layout.fragment_roots, container, false);
    mList = (ExpandableListView) view.findViewById(android.R.id.list);
    mList.setOnChildClickListener(mItemListener);
    mList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);

    DisplayMetrics metrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
    int width = Utils.dpToPx(302);

    boolean rtl = Utils.isRTL();
    int leftPadding = rtl ? 10 : 50;
    int rightPadding = rtl ? 50 : 10;
    int leftWidth = width - Utils.dpToPx(leftPadding);
    int rightWidth = width - Utils.dpToPx(rightPadding);

    if(Utils.hasJellyBeanMR2()){
        mList.setIndicatorBoundsRelative(leftWidth, rightWidth);

    } else {
        mList.setIndicatorBounds(leftWidth, rightWidth);
    }
    return view;
}
 
Example 13
Source Project: FireFiles   File: RootsFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(
        LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    final View view = inflater.inflate(R.layout.fragment_roots, container, false);
    mList = (ExpandableListView) view.findViewById(android.R.id.list);
    mList.setOnChildClickListener(mItemListener);
    mList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);

    DisplayMetrics metrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
    int width = Utils.dpToPx(302);

    boolean rtl = Utils.isRTL();
    int leftPadding = rtl ? 10 : 50;
    int rightPadding = rtl ? 50 : 10;
    int leftWidth = width - Utils.dpToPx(leftPadding);
    int rightWidth = width - Utils.dpToPx(rightPadding);

    if(Utils.hasJellyBeanMR2()){
        mList.setIndicatorBoundsRelative(leftWidth, rightWidth);

    } else {
        mList.setIndicatorBounds(leftWidth, rightWidth);
    }
    return view;
}
 
Example 14
Source Project: qplayer-sdk   File: SettingView.java    License: MIT License 5 votes vote down vote up
private void init() {    	
    mInflater = LayoutInflater.from(this);
    initData();
    mAdapter = new MyExpandableListViewAdapter();
    mListView = (ExpandableListView) findViewById(R.id.my_list);
    mListView.setAdapter(mAdapter);
    mListView.setOnGroupClickListener(this);
    mListView.setOnChildClickListener(this);
    mListView.setOnGroupExpandListener(this);
}
 
Example 15
Source Project: BleSensorTag   File: DeviceServicesActivity.java    License: MIT License 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.device_services_activity);

    gattServicesList = (ExpandableListView) findViewById(R.id.gatt_services_list);
    gattServicesList.setOnChildClickListener(this);
    final View emptyView = findViewById(R.id.empty_view);
    gattServicesList.setEmptyView(emptyView);

    dataCharacteristic = (TextView) findViewById(R.id.data_characteristic_uuid);
    dataValue = (TextView) findViewById(R.id.data_characteristic_value);

    //noinspection ConstantConditions
    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    final ActionBar actionBar = getSupportActionBar();
    final String deviceName = getDeviceName();
    if (TextUtils.isEmpty(deviceName)) {
        //noinspection ConstantConditions
        actionBar.setTitle(getDeviceAddress());
    } else {
        //noinspection ConstantConditions
        actionBar.setTitle(deviceName);
        actionBar.setSubtitle(getDeviceAddress());
    }
    actionBar.setDisplayHomeAsUpEnabled(true);
}
 
Example 16
Source Project: AndroidSDK   File: ApiTestFragment.java    License: MIT License 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    mInflater = inflater;
    View v = inflater.inflate(R.layout.fragment_api_test, container, false);
    mProgressDialog = new ProgressDialog(getActivity());
    mProgressDialog.setMessage("Sending request...");

    mExpandableListView = (ExpandableListView) v.findViewById(R.id.expandable_list_view);
    mExpandableListView.setGroupIndicator(null);
    initData();
    mExpandableListView.setOnChildClickListener(this);
    return v;
}
 
Example 17
Source Project: 365browser   File: RecentTabsPage.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Constructor returns an instance of RecentTabsPage.
 *
 * @param activity The activity this view belongs to.
 * @param recentTabsManager The RecentTabsManager which provides the model data.
 */
public RecentTabsPage(ChromeActivity activity, RecentTabsManager recentTabsManager) {
    mActivity = activity;
    mRecentTabsManager = recentTabsManager;

    mTitle = activity.getResources().getString(R.string.recent_tabs);
    mThemeColor = ApiCompatibilityUtils.getColor(
            activity.getResources(), R.color.default_primary_color);
    mRecentTabsManager.setUpdatedCallback(this);
    LayoutInflater inflater = LayoutInflater.from(activity);
    mView = (ViewGroup) inflater.inflate(R.layout.recent_tabs_page, null);
    mListView = (ExpandableListView) mView.findViewById(R.id.odp_listview);
    mAdapter = new RecentTabsRowAdapter(activity, recentTabsManager);
    mListView.setAdapter(mAdapter);
    mListView.setOnChildClickListener(this);
    mListView.setGroupIndicator(null);
    mListView.setOnGroupCollapseListener(this);
    mListView.setOnGroupExpandListener(this);
    mListView.setOnCreateContextMenuListener(this);

    mView.addOnAttachStateChangeListener(this);
    ApplicationStatus.registerStateListenerForActivity(this, activity);
    // {@link #mInForeground} will be updated once the view is attached to the window.

    if (activity.getBottomSheet() != null) {
        View recentTabsRoot = mView.findViewById(R.id.recent_tabs_root);
        ApiCompatibilityUtils.setPaddingRelative(recentTabsRoot,
                ApiCompatibilityUtils.getPaddingStart(recentTabsRoot), 0,
                ApiCompatibilityUtils.getPaddingEnd(recentTabsRoot),
                activity.getResources().getDimensionPixelSize(
                        R.dimen.bottom_control_container_height));
    }

    onUpdated();
}
 
Example 18
@Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.gatt_services_characteristics);

      final Intent intent = getIntent();
      deviceName = intent.getStringExtra(EXTRAS_DEVICE_NAME);
      deviceAddress = intent.getStringExtra(EXTRAS_DEVICE_ADDRESS);

      // Sets up UI references.
      ((TextView) findViewById(R.id.device_address)).setText(deviceAddress);
      gattServicesList = (ExpandableListView) findViewById(R.id.gatt_services_list);
      gattServicesList.setOnChildClickListener(servicesListClickListner);
      connectionState = (TextView) findViewById(R.id.connection_state);
      dataField = (TextView) findViewById(R.id.data_value);
heartRateField = (TextView) findViewById(R.id.heartrate_value);

demoButton = (Button) findViewById(R.id.demo);

demoButton.setOnClickListener(new View.OnClickListener() {
	@Override
	public void onClick(View v) {
		Log.d(TAG, "onClick serviceListener: "+serviceListener);
		if (serviceListener == null)
			return;
		final BluetoothGattService service = gattServiceAdapter.getHeartRateService();
		serviceListener.onDemoClick(service);
		Log.d(TAG, "set service listener");
	}
});

demoButton.setVisibility(View.VISIBLE);
      
      getActionBar().setTitle(deviceName);
      getActionBar().setDisplayHomeAsUpEnabled(true);

      final Intent gattServiceIntent = new Intent(this, BleService.class);
      bindService(gattServiceIntent, serviceConnection, BIND_AUTO_CREATE);
  }
 
Example 19
Source Project: weixin   File: AddressBookFragment.java    License: Apache License 2.0 5 votes vote down vote up
private void initView(View v) {
	mElv_addressbook = (ExpandableListView) v.findViewById(R.id.cgt_elv_addressbook);
	mV_addressbook_right = (AssortView) v.findViewById(R.id.cgt_v_addressbook_right);

	mElv_addressbook.setOnItemLongClickListener(this);
	mElv_addressbook.setOnChildClickListener(this);
}
 
Example 20
Source Project: MaterialQQLite   File: ContactsFragment.java    License: Apache License 2.0 4 votes vote down vote up
private void initView() {
       m_QQClient = AppData.getAppData().getQQClient();
       m_buddyList = m_QQClient.getBuddyList();

//	m_btnBuddyTeam = (Button)getActivity().findViewById(R.id.contacts_btnBuddyTeam);
//	m_btnAllBuddy = (Button)getActivity().findViewById(R.id.contacts_btnAllBuddy);
	mListView = (ExpandableListView)getActivity().findViewById(R.id.expandableListView);
//	m_btnGroup = (ImageButton)getActivity().findViewById(R.id.contacts_btnGroup);
       swipeRefreshLayout_freind= (PullRefreshLayout) getActivity().findViewById(R.id.swipeRefreshLayout_friend);
//	m_btnBuddyTeam.setOnClickListener(this);
//	m_btnAllBuddy.setOnClickListener(this);
//	m_btnGroup.setOnClickListener(this);

       //ExpandableListView actualListView = mListView.getRefreshableView();
       mListView.setGroupIndicator(null);
       m_blistAdapter = new BuddyListAdapter(getActivity(), m_buddyList);
       mListView.setAdapter(m_blistAdapter);
       mListView.setDescendantFocusability(
       		ExpandableListView.FOCUS_AFTER_DESCENDANTS);
       mListView.setOnChildClickListener(this);
       
   //    mListView.getLoadingLayoutProxy().setPullLabel("下拉刷新");
   //    mListView.getLoadingLayoutProxy().setReleaseLabel("释放立即刷新");
   //    mListView.getLoadingLayoutProxy().setRefreshingLabel("正在刷新...");
   //    mListView.getLoadingLayoutProxy().setLastUpdatedLabel("");

       swipeRefreshLayout_freind.setOnRefreshListener(new PullRefreshLayout.OnRefreshListener() {
           @Override
           public void onRefresh() {
               new GetDataTask().execute();
               swipeRefreshLayout_freind.postDelayed(new Runnable() {
                   @Override
                   public void run() {
                       swipeRefreshLayout_freind.setRefreshing(false);
                       refresh();
                       // m_glistAdapter.notifyDataSetChanged();
                   }
               }, 1000);
           }
       });
}