List of usage examples for android.widget ListView setAdapter
@Override public void setAdapter(ListAdapter adapter)
From source file:com.cssweb.android.base.BaseActivity.java
private void setAdapter(ListView localListView, boolean flag) { int len = initBitmap(); adapter = new MenuAdapter(this, len); localListView.setAdapter(adapter); localListView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String menuName = (String) (parent.getItemAtPosition(position)); MenuUtils.toMenu(BaseActivity.this, menuName); openMenu();//from w w w . j a va 2 s . co m } }); }
From source file:biz.easymenu.easymenung.MenuPagerAdapter.java
private Object instantiateItemList(View pager, int position) { View v = li.inflate(R.layout.menupager1, null); ListView listview = (ListView) v.findViewById(R.id.list); TextView tv = (TextView) v.findViewById(R.id.menuTitle); tv.setText(menuTitles.get(position).getLabel()); ItemAdapter adapter = new ItemAdapter(context, position); ItemAdaptersList.add(position, adapter); listview.setAdapter(adapter); listview.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View v, int position, long id) { //Toast.makeText(context, "" + position, Toast.LENGTH_SHORT).show(); FragmentManager fm = ((FragmentActivity) context).getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); DialogFragment f = new ItemFragment((DBRowItem) parent.getAdapter().getItem(position)); Fragment prev = fm.findFragmentByTag("itemDialog"); if (prev != null) { ft.remove(prev);//from w w w .j a v a2 s .c om ft.commit(); } f.show(ft, "itemDialog"); } }); ((ViewPager) pager).addView(v, 0); return v; }
From source file:com.coderdojo.libretalk.MainActivity.java
public void addMessage(View view) { EditText messageEditText = (EditText) findViewById(R.id.edit_message); String message = messageEditText.getText().toString(); messageEditText.setText(""); ArrayAdapter<SpannableString> adapter = new ArrayAdapter<SpannableString>(this, android.R.layout.simple_list_item_1, mMessageListArray); ListView listView = (ListView) findViewById(R.id.message_list); listView.setAdapter(adapter); listView.setStackFromBottom(true);/*from w w w . j ava 2 s. c o m*/ //mMessageListArray.add(new String(message)); //adapter.notifyDataSetChanged(); //XXX NETWORKING CODE BEGIN if (!message.isEmpty()) { if (message.startsWith(".nick")) { this.nick = message.substring(5); printMsg("\t >> Changed your nickname to " + this.nick); return; } final LibretalkMessageData data = new LibretalkMessageData(this.nick, message); this.sender.send(LibretalkMessageData.serialize(data).getBytes(), this.connection.getUserTag()); } //XXX NETWORKING CODE END }
From source file:com.ehelp.home.SuperAwesomeCardFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); FrameLayout fl = new FrameLayout(getActivity()); fl.setLayoutParams(params);// w w w. ja v a 2s. c om //fl.setBackgroundColor(0x666666); final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); TextView v = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v.setLayoutParams(params); v.setGravity(Gravity.TOP); System.out.println(position); if (position == 0) { fl.removeAllViews(); mCurrentMode = MyLocationConfiguration.LocationMode.NORMAL; mMapView = new MapView(getActivity()); mMapView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); fl.addView(mMapView); mBaiduMap = mMapView.getMap(); // ?? mBaiduMap.setMyLocationEnabled(true); // ?? mLocClient = new LocationClient(getActivity()); mLocClient.registerLocationListener(myListener); LocationClientOption option = new LocationClientOption(); option.setOpenGps(true);// gps option.setCoorType("bd09ll"); // ?? option.setScanSpan(1000); mLocClient.setLocOption(option); mLocClient.start(); int count = mMapView.getChildCount(); for (int i = 0; i < count; i++) { View child = mMapView.getChildAt(i); if (child instanceof ZoomControls || child instanceof ImageView) { child.setVisibility(View.INVISIBLE); } } setLocation(); } else if (position == 1) { fl.removeAllViews(); ListView queList = new ListView(getActivity()); queList.setLayoutParams(new LinearLayout.LayoutParams(-1, -1)); HomeAdapter que = new HomeAdapter(getActivity(), user_id, 2, eventCache); queList.setAdapter(que); queList.setDividerHeight(20); fl.addView(queList); events = que.getEvent(); //? queList.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> arg0, View arg1, int index, long arg3) { Intent intent = new Intent(getActivity(), recievesos_map.class); int eventid = events.get(index).getEventId(); intent.putExtra(EXTRA_MESSAGE, eventid); startActivity(intent); } }); } else if (position == 2) { fl.removeAllViews(); ListView queList = new ListView(getActivity()); queList.setLayoutParams(new LinearLayout.LayoutParams(-1, -1)); //queList.setBackgroundColor(0x666666); //queList.setAlpha(125); queList.setDividerHeight(20); HomeAdapter que = new HomeAdapter(getActivity(), user_id, 1, eventCache); queList.setAdapter(que); fl.addView(queList); events = que.getEvent(); //? queList.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> arg0, View arg1, int index, long arg3) { Intent intent = new Intent(getActivity(), recieve_help_ans_map.class); intent.putExtra(EXTRA_MESSAGE, events.get(index)); startActivity(intent); } }); } else if (position == 3) { fl.removeAllViews(); ListView queList = new ListView(getActivity()); queList.setLayoutParams(new LinearLayout.LayoutParams(-1, -1)); HomeAdapter que = new HomeAdapter(getActivity(), user_id, 0, eventCache); queList.setAdapter(que); queList.setDividerHeight(20); fl.addView(queList); events = que.getEvent(); //? queList.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> arg0, View arg1, int index, long arg3) { Intent intent = new Intent(getActivity(), QuestionDetail.class); intent.putExtra("qusetiondatail", events.get(index)); startActivity(intent); } }); } return fl; }
From source file:app.abhijit.iter.MainActivity.java
private void setupListAdapters() { ListView studentsList = (ListView) findViewById(R.id.list_students); mStudentsAdapter = new StudentsAdapter(new ArrayList<Student>()); studentsList.setAdapter(mStudentsAdapter); ListView subjectsList = (ListView) findViewById(R.id.list_subjects); mSubjectsAdapter = new SubjectsAdapter(new ArrayList<Subject>()); subjectsList.setAdapter(mSubjectsAdapter); }
From source file:com.rvl.android.getnzb.Search.java
public void buildItemList(int numhits) { String hits[][] = HITLIST;/*from w w w . jav a2 s . c o m*/ setContentView(R.layout.links); String item = ""; Log.d(Tags.LOG, "* buildItemList()"); if (numhits == 0) { Toast.makeText(this, "No search result found!", Toast.LENGTH_LONG); return; } // -- Bind the itemlist to the itemarray with the arrayadapter ArrayList<String> items = new ArrayList<String>(); ArrayAdapter<String> aa = new SearchResultRowAdapter(this, items); //ArrayAdapter<String> aa = new ArrayAdapter<String>(this,com.rvl.android.getnzb.R.layout.itemslist,items); ListView itemlist = (ListView) findViewById(R.id.itemlist01); itemlist.setCacheColorHint(00000000); itemlist.setAdapter(aa); registerForContextMenu(itemlist); itemlist.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View v, int position, long id) { String pos = Integer.toString(position); Log.d(Tags.LOG, "Sending download command for position " + pos); new downloadfile().execute(pos); } }); // -- Log.d(Tags.LOG, "Building hitlist..."); for (int i = 0; i < hits.length; i++) { item += hits[i][0] + "#" + hits[i][1] + "#" + hits[i][2] + "#" + hits[i][4]; items.add(item); Log.d(Tags.LOG, "item:" + item); item = ""; } aa.notifyDataSetChanged(); // Enable or disable the button for next results page... Button nextbutton = (Button) findViewById(R.id.btn_next); nextbutton.setEnabled(ENABLE_NEXTBUTTON); }
From source file:system.info.reader.java
public void showMyDialog(String[] valuse) { ArrayAdapter itemAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, valuse); View myView = getLayoutInflater().inflate(R.layout.popup, (ViewGroup) findViewById(R.id.popup_root)); ListView itemView = (ListView) myView.findViewById(R.id.PropertyList); itemView.setAdapter(itemAdapter); itemView.setOnItemClickListener(msubitemCL); AlertDialog altDialog = new AlertDialog.Builder(this).setView(myView).create(); altDialog.setOnKeyListener(null);// w w w .j a v a 2 s .c o m m_altDialog = altDialog; altDialog.show(); }
From source file:com.coderdojo.libretalk.MainActivity.java
private final void printMsg(final LibretalkMessageData message) { ArrayAdapter<SpannableString> adapter = new ArrayAdapter<SpannableString>(this, android.R.layout.simple_list_item_1, mMessageListArray); ListView listView = (ListView) findViewById(R.id.message_list); listView.setAdapter(adapter); listView.setStackFromBottom(true);//from w ww. j a v a2 s . c om final String sourceMessage = message.getSenderTag() + ": " + message.getData(); final SpannableString formattedText = new SpannableString(sourceMessage); if (message.getData().startsWith(">")) { formattedText.setSpan( new ForegroundColorSpan(LibretalkMessageData.getColorFromString(message.getSenderTag())), sourceMessage.indexOf(message.getSenderTag()), sourceMessage.indexOf(message.getSenderTag()) + message.getSenderTag().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); formattedText.setSpan(new ForegroundColorSpan(Color.rgb(120, 153, 34)), sourceMessage.indexOf(message.getData()), sourceMessage.indexOf(message.getData()) + message.getData().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } else { formattedText.setSpan( new ForegroundColorSpan(LibretalkMessageData.getColorFromString(message.getSenderTag())), sourceMessage.indexOf(message.getSenderTag()), sourceMessage.indexOf(message.getSenderTag()) + message.getSenderTag().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } mMessageListArray.add(formattedText); adapter.notifyDataSetChanged(); }
From source file:com.digium.respoke.ChatActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_chat); getActionBar().setDisplayHomeAsUpEnabled(true); Button buttonSend = (Button) findViewById(R.id.buttonSend); EditText chatText = (EditText) findViewById(R.id.chatText); chatText = (EditText) findViewById(R.id.chatText); chatText.setOnKeyListener(new View.OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { sendChatMessage();//from w ww.ja va 2 s .c o m return true; } return false; } }); buttonSend.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { sendChatMessage(); } }); String remoteEndpointID = null; boolean shouldStartDirectConnection = false; // Check whether we're recreating a previously destroyed instance if (savedInstanceState != null) { remoteEndpointID = savedInstanceState.getString(ENDPOINT_ID_KEY); shouldStartDirectConnection = savedInstanceState.getBoolean(DIRECT_CONNECTION_KEY, false); } else { Bundle extras = getIntent().getExtras(); if (extras != null) { remoteEndpointID = extras.getString(ENDPOINT_ID_KEY); shouldStartDirectConnection = extras.getBoolean(DIRECT_CONNECTION_KEY, false); } else { // The activity must have been destroyed while it was hidden to save memory. Use the most recent persistent data. SharedPreferences prefs = getSharedPreferences(ConnectActivity.RESPOKE_SETTINGS, 0); remoteEndpointID = prefs.getString(ENDPOINT_ID_KEY, ""); shouldStartDirectConnection = prefs.getBoolean(DIRECT_CONNECTION_KEY, false); } } conversation = ContactManager.sharedInstance().conversations.get(remoteEndpointID); remoteEndpoint = ContactManager.sharedInstance().sharedClient.getEndpoint(remoteEndpointID, true); setTitle(remoteEndpoint.getEndpointID()); listAdapter = new ListDataAdapter(); ListView lv = (ListView) findViewById(R.id.list); //retrieve the instance of the ListView from your main layout lv.setAdapter(listAdapter); //assign the Adapter to be used by the ListView if (shouldStartDirectConnection && (null == remoteEndpoint.directConnection())) { // If the direct connection has not been started yet, start it now remoteEndpoint.startDirectConnection(); } directConnection = remoteEndpoint.directConnection(); if (null != directConnection) { directConnection.setListener(this); RespokeCall call = directConnection.getCall(); boolean caller = false; if (null != call) { call.setListener(this); caller = call.isCaller(); } View answerView = findViewById(R.id.answer_view); View connectingView = findViewById(R.id.connecting_view); TextView callerNameView = (TextView) findViewById(R.id.caller_name_text); if (caller) { answerView.setVisibility(View.INVISIBLE); connectingView.setVisibility(View.VISIBLE); } else { answerView.setVisibility(View.VISIBLE); connectingView.setVisibility(View.INVISIBLE); } if (null != remoteEndpoint) { callerNameView.setText(remoteEndpoint.getEndpointID()); } else { callerNameView.setText("Unknown Caller"); } ActionBar actionBar = getActionBar(); actionBar.setBackgroundDrawable(new ColorDrawable(R.color.incoming_connection_bg)); actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayShowTitleEnabled(true); } }
From source file:com.google.cast.samples.games.codelab.DrawingFragment.java
/** * Set the list of words to display for guessing. *//* w w w .ja v a 2s .c o m*/ private void resetWords(List<String> words) { if (words != null) { ListView list = (ListView) getView().findViewById(R.id.listView); ArrayAdapter<String> adapter = new ArrayAdapter<String>(getView().getContext(), R.layout.list_item, R.id.text, words); list.setAdapter(adapter); } }