List of usage examples for android.widget GridView setAdapter
@Override public void setAdapter(ListAdapter adapter)
From source file:org.linphone.ServicesFragment.java
@Override public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { infl = inflater;// w w w . j ava 2 s .co m View view = inflater.inflate(R.layout.services_list, container, false); LinphoneActivity.instance().hideStatusBar(); registered = LinphoneManager.getLc().getDefaultProxyConfig() != null && LinphoneManager.getLc().getDefaultProxyConfig().isRegistered(); noIndustryTextView = (TextView) view.findViewById(R.id.noIndustry); noIndustryServiceTextView = (TextView) view.findViewById(R.id.noIndustryService); noFavouriteServiceTextView = (TextView) view.findViewById(R.id.noFavouriteService); industriesServiceWrapper = (GridView) view.findViewById(R.id.industry_service_wrapper); favouriteLayout = (LinearLayout) view.findViewById(R.id.layout_favourite_wrap); industriesButton = (Button) view.findViewById(R.id.industries_button); industriesLayout = (LinearLayout) view.findViewById(R.id.layout_service_wrap); gobackButton = (ImageView) view.findViewById(R.id.goback); gobackButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { onBackPressed(); } }); serviceTitleTextView = (TextView) view.findViewById(R.id.service_title); industriesButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { showIndustriesView(inflater); } }); GridView favouriteWrapper = (GridView) view.findViewById(R.id.favourite_wrapper); try { if (LocalBundleData.favouriteServiceList == null) { LocalBundleData.favouriteServiceList = WebserviceUtil.apiGetFavouriteServices(); } if (LocalBundleData.favouriteServiceList.isEmpty()) { noFavouriteServiceTextView.setVisibility(View.VISIBLE); } else { noFavouriteServiceTextView.setVisibility(View.GONE); } favouriteWrapper.setAdapter( new ImageAdapter(LinphoneActivity.instance(), LocalBundleData.favouriteServiceList, inflater)); favouriteWrapper.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View v, int position, long id) { ServiceDTO serviceDTO = LocalBundleData.favouriteServiceList.get(position); boolean active = ServiceDTO.SERVICE_STATUS_ACTIVE .equalsIgnoreCase(serviceDTO.getServiceStatus()); if (active && registered) { String address = serviceDTO.getServiceDialCode(); String serviceName = serviceDTO.getServiceName(); callService(address, serviceName); } } }); } catch (WebserviceCallingFailedException e) { e.printStackTrace(); } LinphoneManager.getLc().addListener(mListener = new LinphoneCoreListenerBase() { @Override public void callState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State state, String message) { // nothing } @Override public void globalState(LinphoneCore lc, LinphoneCore.GlobalState state, String message) { // nothing } @Override public void registrationState(LinphoneCore lc, LinphoneProxyConfig cfg, LinphoneCore.RegistrationState state, String smessage) { if (state == RegistrationState.RegistrationOk && LinphoneManager.getLc().getDefaultProxyConfig() != null && LinphoneManager.getLc().getDefaultProxyConfig().isRegistered()) { registered = true; } else { registered = false; } } }); return view; }
From source file:com.openerp.addons.messages.MessageDetail.java
/** * Sets the up list view.//from w ww. j av a 2 s .c o m * * @param list * the new up list view */ private boolean setupListView(final List<OEListViewRows> list) { // Handling List View controls and keys String[] from = new String[] { "image", "email_from|name", "email_from|email", "body", "date", "partners", "starred", "vote_nb" }; int[] to = new int[] { R.id.imgUserPicture, R.id.txvMessageAuthor, R.id.txvAuthorEmail, R.id.webViewMessageBody, R.id.txvTime, R.id.txvTo, R.id.imgBtnStar, R.id.txvmessageVotenb }; // Creating instance for listAdapter listAdapter = new OEListViewAdapter(scope.context(), R.layout.message_detail_listview_items, list, from, to, db); listAdapter.toHTML("body", true); listAdapter.addImageColumn("image"); // listAdapter.layoutBackgroundColor("parent_id", // Color.parseColor("#aaaaaa"), Color.parseColor("#0099cc")); listAdapter.cleanDate("date", scope.User().getTimezone(), "MMM dd, yyyy, hh:mm a"); listAdapter.addViewListener(new OEListViewOnCreateListener() { @Override public View listViewOnCreateListener(final int position, View row_view, OEListViewRows row_data) { final int message_id = row_data.getRow_id(); final HashMap<String, Object> row_values = row_data.getRow_data(); /* handling vote control */ final TextView txvVote = (TextView) row_view.findViewById(R.id.txvmessageVotenb); final int vote_nb = Integer.parseInt(row_data.getRow_data().get("vote_nb").toString()); if (vote_nb == 0) { txvVote.setText(""); } final boolean hasVoted = Boolean.parseBoolean(row_data.getRow_data().get("has_voted").toString()); if (!hasVoted) { txvVote.setCompoundDrawablesWithIntrinsicBounds( getResources().getDrawable(R.drawable.ic_thumbs_up_unselected_dark_tablet), null, null, null); // txvVote.setBackgroundResource(R.drawable.vote_background_selector_gray); } else { // txvVote.setBackgroundResource(R.drawable.vote_background_selector_blue); txvVote.setCompoundDrawablesWithIntrinsicBounds( getResources().getDrawable(R.drawable.ic_thumbs_up_selected_dark_tablet), null, null, null); } txvVote.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { MessageVoteToggle voteToggle = new MessageVoteToggle(message_id, vote_nb, hasVoted); String newVote = ""; boolean btnvoted = false; if (hasVoted) { newVote = (vote_nb - 1) + ""; row_values.put("has_voted", "false"); } else { btnvoted = true; newVote = (vote_nb + 1) + ""; row_values.put("has_voted", "true"); } row_values.put("vote_nb", newVote); listAdapter.updateRow(position, new OEListViewRows(message_id, row_values)); voteToggle.execute((Void) null); txvVote.setText(newVote); if (!btnvoted) { txvVote.setCompoundDrawablesWithIntrinsicBounds( getResources().getDrawable(R.drawable.ic_thumbs_up_unselected_dark_tablet), null, null, null); // txvVote.setBackgroundResource(R.drawable.vote_background_selector_gray); } else { // txvVote.setBackgroundResource(R.drawable.vote_background_selector_blue); txvVote.setCompoundDrawablesWithIntrinsicBounds( getResources().getDrawable(R.drawable.ic_thumbs_up_selected_dark_tablet), null, null, null); } } }); /* handling attachments */ List<OEListViewRows> attachments = getAttachmentsOfMessage(row_data.getRow_id() + ""); int index = 0; if (attachments.size() > 0) { LayoutInflater vi = (LayoutInflater) scope.context().getApplicationContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View insertPoint = row_view.findViewById(R.id.gridAttachments); ((ViewGroup) insertPoint).removeAllViews(); for (OEListViewRows row : attachments) { View v = vi.inflate(R.layout.fragment_message_detail_attachment_grid_item, null, true); TextView txvAttachmentName = (TextView) v.findViewById(R.id.txvFileName); txvAttachmentName.setText(row.getRow_data().get("name").toString()); TextView txvAttachmentSize = (TextView) v.findViewById(R.id.txvFileSize); long fileSize = Long.parseLong(row.getRow_data().get("file_size").toString()); String file_size = OEFileSizeHelper.readableFileSize(fileSize); txvAttachmentSize.setText((file_size.equals("0")) ? " " : file_size); TextView txvAttachmentId = (TextView) v.findViewById(R.id.txvAttachmentId); txvAttachmentId.setText(String.valueOf(row.getRow_id())); ((ViewGroup) insertPoint).addView(v, index, new ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); v.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { int attachment_id = Integer.parseInt( ((TextView) v.findViewById(R.id.txvAttachmentId)).getText().toString()); OEBinaryDownloadHelper binaryDownload = new OEBinaryDownloadHelper(); binaryDownload.downloadBinary(attachment_id, db); } }); index++; } } else { row_view.findViewById(R.id.layoutMessageAttachments).setVisibility(View.GONE); } OEContactView oe_contactView = (OEContactView) row_view.findViewById(R.id.imgUserPicture); int partner_id = Integer.parseInt(row_data.getRow_data().get("partner_id").toString()); oe_contactView.assignPartnerId(partner_id); return row_view; } }); listAdapter.setItemClickListener(R.id.imgBtnReply, new ControlClickEventListener() { @Override public OEListViewRows controlClicked(int position, OEListViewRows row, View view) { Intent composeIntent = new Intent(scope.context(), MessageComposeActivty.class); composeIntent.putExtra("message_id", message_id); composeIntent.putExtra("send_reply", true); startActivityForResult(composeIntent, MESSAGE_REPLY); return null; } }); // Setting callback handler for boolean field value change. listAdapter.setBooleanEventOperation("starred", R.drawable.ic_action_starred, R.drawable.ic_action_unstarred, updateStarred); GridView lstview = (GridView) rootView.findViewById(R.id.lstMessageDetail); // Providing adapter to listview lstview.setAdapter(listAdapter); return true; }
From source file:dynamite.zafroshops.app.fragment.AllZopsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_all_zops, container, false); GridView gridView = (GridView) rootView.findViewById(R.id.gridViewZops); if (adapter.getCount() > 0) { rootView.findViewById(R.id.relativeLayoutLoader).setVisibility(View.INVISIBLE); }/*from w w w .j a va2s.c o m*/ gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { MobileZop item = (MobileZop) parent.getAdapter().getItem(position); ((MainActivity) getActivity()).nextMenu(TypedZopsFragment.newInstance(item.Type, false), true, 10); } }); gridView.setAdapter(adapter); return rootView; }
From source file:com.google.devrel.samples.memedroid.app.CreateActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); overridePendingTransition(R.anim.translate_in_top, R.anim.translate_out_top); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setContentView(R.layout.activity_create); if (getActionBar() != null) { getActionBar().setDisplayHomeAsUpEnabled(true); }//from w ww . ja v a2s.co m mHandler = new Handler(); ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager); GridView gridView = (GridView) findViewById(R.id.template_grid); if (viewPager != null) { PagerAdapter adapter = new MemeTemplatePagerAdapter(getSupportFragmentManager()); viewPager.setAdapter(adapter); mAdapter = (TemplateAdapter) adapter; viewPager.setOffscreenPageLimit(3); viewPager.setPageMargin(-54); viewPager.setOnPageChangeListener(this); mCurrentView = viewPager; findViewById(R.id.meme_template_number).setVisibility(View.VISIBLE); } else if (gridView != null) { ListAdapter adapter = new MemeTemplateAdapter(this, R.layout.fragment_meme); gridView.setAdapter(adapter); mAdapter = (TemplateAdapter) adapter; mCurrentView = gridView; gridView.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE); gridView.setOnItemClickListener(this); } else { throw new IllegalStateException("No valid layout found."); } getSupportLoaderManager().initLoader(MEME_TEMPLATE_LIST, null, this); if (savedInstanceState != null) { mHasText = savedInstanceState.getBoolean(STATE_TEXT, false); getSupportLoaderManager().restartLoader(MEME_TEMPLATE_LIST, null, CreateActivity.this); } EditText et = (EditText) findViewById(R.id.top_text); et.addTextChangedListener(this); setProgressBarIndeterminateVisibility(true); }
From source file:com.example.spencerdepas.translationapp.activities.DMVStudyActivity.java
private void showSelectQuestionDialog() { Log.d(TAG, "showAlertDialog"); // Prepare grid view GridView gridView = new GridView(this); int questionSize = driverQuestions.getQuestions().size(); List<Integer> mList = new ArrayList<Integer>(); for (int i = 1; i < questionSize + 1; i++) { mList.add(i);//from w ww . j ava2s . c om } gridView.setAdapter(new ArrayAdapter<Integer>(this, R.layout.custom_list_item, mList) { @Override public View getView(int position, View convertView, ViewGroup parent) { View view = super.getView(position, convertView, parent); boolean hasBeenAnswered = hasBeenAnswered(position); Log.d(TAG, "hasBeenAnswered : " + hasBeenAnswered); int color = 0x00FFFFFF; // Transparent if (hasBeenAnswered) { if (driverQuestions.getQuestions().get(position).isAnsweredCorrectly()) { //answer is correct view.setBackgroundColor(getResources().getColor(R.color.colorForQuestionGrid)); } else { //answer is incorrect view.setBackgroundColor(getResources().getColor(R.color.red)); } } else { view.setBackgroundColor(color); } return view; } }); gridView.setNumColumns(4); // Set grid view to alertDialog final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setView(gridView); builder.setTitle(getResources().getString(R.string.select_question)); builder.setPositiveButton(getResources().getString(R.string.dialog_dismiss), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Log.d(TAG, getResources().getString(R.string.dialog_dismiss)); dialog.dismiss(); } }); final AlertDialog ad = builder.show(); gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // do something here Log.d(TAG, "onclick"); if (position == 0) { makePrevousButtonUnclickable(); } else { makePrevousButtonClickable(); } mNextButton.setText(getResources().getString(R.string.next_button)); Log.d(TAG, "int pos : " + position); if (position == 193) { mNextButton.setText(getResources().getString(R.string.finish_studying)); } goToSelectedQuestion(position); ad.dismiss(); } }); }
From source file:com.rsatyavolu.nanodegree.popularmovies.MainActivityFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View rootView = inflater.inflate(R.layout.fragment_main, container, false); GridView gridView = (GridView) rootView.findViewById(R.id.gridview); gridView.setColumnWidth(200);//from w ww . j a va2s .c om gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (parent.getItemAtPosition(position) != null) { ((Callback) getActivity()).onItemSelected(movieListAdapter.getItem(position)); } } }); if (savedInstanceState != null) { data = (List<MovieItemModel>) savedInstanceState.getSerializable(MOVIE_SEARCH_RESULTS); } else { data = new ArrayList<MovieItemModel>(); } movieListAdapter = new MovieIconViewAdapter(getActivity(), data); gridView.setAdapter(movieListAdapter); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); PreferenceManager.setDefaultValues(getActivity(), R.xml.pref_settings, false); String apiToken = prefs.getString(getString(R.string.pref_api_token_key), ""); String sortOption = prefs.getString(getString(R.string.pref_sort_key), ""); if (apiToken.length() <= 25) { Intent settings = new Intent(getActivity(), SettingsActivity.class); startActivity(settings); return rootView; } if (data.size() == 0) { DiscoverMoviesTask discoverMoviesTask = new DiscoverMoviesTask(); discoverMoviesTask.execute(DISCOVER_MOVIES_URL, apiToken, sortOption); } return rootView; }
From source file:com.android.view.leg.ImageGridForLeg.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View v = inflater.inflate(R.layout.image_grid_fragment, container, false); final GridView mGridView = (GridView) v.findViewById(R.id.gridView); final TextView mTextView = (TextView) v.findViewById(R.id.title_text); mTextView.setText(getString(R.string.main_leg)); ImageButton mImageButton = (ImageButton) v.findViewById(R.id.category_recomment); mImageButton.setVisibility(View.GONE); mImageButton.setOnClickListener(new OnClickListener() { @Override/* w w w . j a v a 2 s .c o m*/ public void onClick(View arg0) { TapjoyConnect.getTapjoyConnectInstance().showOffers(); } }); mGridView.setAdapter(mAdapter); mGridView.setOnItemClickListener(this); mGridView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if (mAdapter.getNumColumns() == 0) { final int numColumns = (int) Math .floor(mGridView.getWidth() / (mImageThumbSize + mImageThumbSpacing)); if (numColumns > 0) { final int columnWidth = (mGridView.getWidth() / numColumns) - mImageThumbSpacing; mAdapter.setNumColumns(numColumns); mAdapter.setItemHeight(columnWidth); if (BuildConfig.DEBUG) { } } } } }); return v; }
From source file:org.vshgap.ui.Components.EmojiView.java
public EmojiView(boolean needStickers, Context context) { super(context); SharedPreferences themePrefs = ApplicationLoader.applicationContext .getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); int bgColor = themePrefs.getInt("chatEmojiViewBGColor", 0xfff5f6f7); int tabColor = themePrefs.getInt("chatEmojiViewTabColor", AndroidUtilities.getIntDarkerColor("themeColor", -0x15)); int lineColor = bgColor == 0xfff5f6f7 ? 0xffe2e5e7 : AndroidUtilities.setDarkColor(bgColor, 0x10); setOrientation(LinearLayout.VERTICAL); for (int i = 0; i < Emoji.data.length; i++) { GridView gridView = new GridView(context); if (AndroidUtilities.isTablet()) { gridView.setColumnWidth(AndroidUtilities.dp(60)); } else {//from www. j ava2 s . c om gridView.setColumnWidth(AndroidUtilities.dp(45)); } gridView.setNumColumns(-1); views.add(gridView); EmojiGridAdapter emojiGridAdapter = new EmojiGridAdapter(Emoji.data[i]); gridView.setAdapter(emojiGridAdapter); //AndroidUtilities.setListViewEdgeEffectColor(gridView, 0xfff5f6f7); AndroidUtilities.setListViewEdgeEffectColor(gridView, bgColor); adapters.add(emojiGridAdapter); } if (needStickers) { GridView gridView = new GridView(context); gridView.setColumnWidth(AndroidUtilities.dp(72)); gridView.setNumColumns(-1); gridView.setPadding(0, AndroidUtilities.dp(4), 0, 0); gridView.setClipToPadding(false); views.add(gridView); stickersGridAdapter = new StickersGridAdapter(context); gridView.setAdapter(stickersGridAdapter); //AndroidUtilities.setListViewEdgeEffectColor(gridView, 0xfff5f6f7); AndroidUtilities.setListViewEdgeEffectColor(gridView, bgColor); } //setBackgroundColor(0xfff5f6f7); setBackgroundColor(bgColor); pager = new ViewPager(context); pager.setAdapter(new EmojiPagesAdapter()); LinearLayout linearLayout = new LinearLayout(context); linearLayout.setOrientation(LinearLayout.HORIZONTAL); //linearLayout.setBackgroundColor(0xfff5f6f7); linearLayout.setBackgroundColor(bgColor); addView(linearLayout, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, AndroidUtilities.dp(48))); PagerSlidingTabStrip tabs = new PagerSlidingTabStrip(context); tabs.setViewPager(pager); tabs.setShouldExpand(true); tabs.setIndicatorHeight(AndroidUtilities.dp(2)); tabs.setUnderlineHeight(AndroidUtilities.dp(1)); //tabs.setIndicatorColor(0xff2b96e2); tabs.setIndicatorColor(tabColor); //tabs.setUnderlineColor(0xffe2e5e7); tabs.setUnderlineColor(lineColor); linearLayout.addView(tabs, new LinearLayout.LayoutParams(0, AndroidUtilities.dp(48), 1.0f)); FrameLayout frameLayout = new FrameLayout(context); linearLayout.addView(frameLayout, new LinearLayout.LayoutParams(AndroidUtilities.dp(52), AndroidUtilities.dp(48))); backspaceButton = new ImageView(context) { @Override public boolean onTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { backspacePressed = true; backspaceOnce = false; postBackspaceRunnable(350); } else if (event.getAction() == MotionEvent.ACTION_CANCEL || event.getAction() == MotionEvent.ACTION_UP) { backspacePressed = false; if (!backspaceOnce) { if (EmojiView.this.listener != null && EmojiView.this.listener.onBackspace()) { backspaceButton.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP); } } } super.onTouchEvent(event); return true; } }; backspaceButton.setImageResource(R.drawable.ic_smiles_backspace); backspaceButton.setBackgroundResource(R.drawable.ic_emoji_backspace); backspaceButton.setScaleType(ImageView.ScaleType.CENTER); frameLayout.addView(backspaceButton, new FrameLayout.LayoutParams(AndroidUtilities.dp(52), AndroidUtilities.dp(48))); View view = new View(context); //view.setBackgroundColor(0xffe2e5e7); view.setBackgroundColor(lineColor); frameLayout.addView(view, new FrameLayout.LayoutParams(AndroidUtilities.dp(52), AndroidUtilities.dp(1), Gravity.LEFT | Gravity.BOTTOM)); recentsWrap = new FrameLayout(context); recentsWrap.addView(views.get(0)); TextView textView = new TextView(context); textView.setText(LocaleController.getString("NoRecent", R.string.NoRecent)); textView.setTextSize(18); textView.setTextColor(0xff888888); textView.setGravity(Gravity.CENTER); recentsWrap.addView(textView); views.get(0).setEmptyView(textView); addView(pager); loadRecents(); if (Emoji.data[0] == null || Emoji.data[0].length == 0) { pager.setCurrentItem(1); } }
From source file:com.near.chimerarevo.fragments.ProductsListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.products_grid_layout, container, false); boolean isLandscapeLarge = false; if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE) isLandscapeLarge = true;//from w w w . j a v a 2 s.c o m } else isLandscapeLarge = false; if (!isLandscapeLarge) v.setPadding(0, getResources().getDimensionPixelSize(R.dimen.actionbar_height), 0, 0); GridView mGrid = (GridView) v.findViewById(R.id.products_grid); mCat = (Spinner) v.findViewById(R.id.category_spinner); mBrand = (Spinner) v.findViewById(R.id.brand_spinner); mLoading = (ProgressWheel) v.findViewById(R.id.product_progress); brandsList = new ArrayList<>(); catList = new ArrayList<>(); catIdList = new ArrayList<>(); arrayList = new ArrayList<>(); mAdapter = new ProductsAdapter(arrayList); if (mGrid != null) { mGrid.setAdapter(mAdapter); mGrid.setOnScrollListener(this); mGrid.setOnItemClickListener(this); } return v; }
From source file:com.example.h156252.connected_cars.CarGrid.java
/** Called when the activity is first created. */ @Override/*from www .j a v a 2 s . c o m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.content_car_grid); try { Window window = getWindow(); // clear FLAG_TRANSLUCENT_STATUS flag: window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); // add FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag to the window window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); // finally change the color window.setStatusBarColor(Color.rgb(0, 0, 0)); android.support.v7.app.ActionBar actionBar = getSupportActionBar(); actionBar.setBackgroundDrawable(new ColorDrawable(Color.rgb(0, 0, 0))); } catch (Exception e) { // Toast.makeText(getApplicationContext(),"Exception in actionbar "+e.getLocalizedMessage(),Toast.LENGTH_SHORT).show(); } session = new SessionManagement(this); tts = new TextToSpeech(this, this); //Toast.makeText(getApplicationContext(),"Entering activity",Toast.LENGTH_SHORT).show(); Intent intent = getIntent(); String result = intent.getStringExtra(HomeScreen.EXTRA_MESSAGE); //Toast.makeText(getApplicationContext(),"obtaining result: " +result,Toast.LENGTH_SHORT).show(); ArrayList<String> listdata = new ArrayList<String>(); try { JSONArray jArray = new JSONArray(result); if (jArray != null) { for (int i = 0; i < jArray.length(); i++) { String jstr = jArray.get(i).toString(); JSONObject jObj = new JSONObject(jstr); String id = jObj.getString("id"); //String phone = jObj.getString("phone"); String brand = jObj.getString("text"); String text = jObj.getString("cartext"); String carno = jObj.getString("carnum"); String color = jObj.getString("color"); //String isDone = jObj.getString("isDone"); String result_combine = "CAR " + i + ":\nCar id : #" + id + "*\n" + "License No. : " + carno + "\n" + "Color : " + color + "\n" + "Brand : " + brand + "\n" + "Text behind car : " + text; String rr = "Success " + result_combine; //Toast.makeText(getApplicationContext(),rr,Toast.LENGTH_SHORT).show(); String own_id = session.getID(); if (!(id.equals(own_id))) listdata.add(result_combine); } } } catch (Exception e) { //Toast.makeText(getApplicationContext(),e.getLocalizedMessage(),Toast.LENGTH_SHORT).show(); } //Toast.makeText(getApplicationContext(),"out of json",Toast.LENGTH_SHORT).show(); final GridView gridview = (GridView) findViewById(R.id.gridview); // final String[] items = new String[] { "Item1", "Item2", "Item3","Item4", "Item5", "Item6", "Item7", "Item8" }; ArrayAdapter<String> ad = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1, listdata); //Toast.makeText(getApplicationContext(),"setting array adapter",Toast.LENGTH_SHORT).show(); //gridview.setBackgroundColor(Color.GRAY); gridview.setNumColumns(2); gridview.setGravity(Gravity.CENTER); gridview.setAdapter(ad); gridview.setBackgroundColor(Color.GRAY); //Toast.makeText(getApplicationContext(),"setting grid view",Toast.LENGTH_SHORT).show(); gridview.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View v, int position, long arg3) { // TODO Auto-generated method stub // Toast.makeText(getApplicationContext(), "" + arg2,Toast.LENGTH_SHORT).show(); //Toast.makeText(getApplicationContext(),"Prompting speech",Toast.LENGTH_SHORT).show(); try { String s = ((TextView) v).getText().toString(); int start = 0; // '(' position in string int end = 0; // ')' position in string for (int i = 0; i < s.length(); i++) { if (s.charAt(i) == '#') // Looking for '(' position in string start = i; else if (s.charAt(i) == '*') // Looking for ')' position in string end = i; } receiver_id = s.substring(start + 1, end); //Toast.makeText(getApplicationContext(), "ID: " + receiver_id, Toast.LENGTH_SHORT).show(); //promptSpeechInput(); } catch (Exception e) { // Toast.makeText(getApplicationContext(), e.getLocalizedMessage(), Toast.LENGTH_SHORT).show(); } //receiver_id = grid_text.substring(grid_text.indexOf("#") + 1, grid_text.indexOf("#")); //Toast.makeText(getApplicationContext(),receiver_id,Toast.LENGTH_SHORT).show(); try { promptSpeechInput(); } catch (Exception e) { //Toast.makeText(getApplicationContext(), e.getLocalizedMessage(), Toast.LENGTH_SHORT).show(); } try { Intent intent_rate = new Intent(getApplicationContext(), RateDriving.class); intent_rate.putExtra(EXTRA_MESSAGE, receiver_id); startActivity(intent_rate); } catch (Exception e) { //Toast.makeText(getApplicationContext(), e.getLocalizedMessage(), Toast.LENGTH_SHORT).show(); } //new VoiceTask().execute("http://myfirst.au-syd.mybluemix.net/api/Items"); } }); }