View getHeader(List<Object> GUIDs, List<Object> Rates, List<Object> Reviews, int MyReviewPos) { // Caculate Average Rate float Sum = 0; for (int i = 0; i < Rates.size(); i++) { try { Sum += (double) Rates.get(i); } catch (Exception E) { Sum += (int) Rates.get(i); } } float Average = Sum / Rates.size(); View v = (View) getActivity().getLayoutInflater().inflate(R.layout.header_review, null); RatingBar AvrRB = (RatingBar) v.findViewById(R.id.rateavr); RatingBar MyRB = (RatingBar) v.findViewById(R.id.myrate); TextView MyReviewTxt = (TextView) v.findViewById(R.id.myreview); AvrRB.setNumStars(5); AvrRB.setRating(Average); if (MyReviewPos != -1) { MyRB.setNumStars(5); try { double d = (double) Rates.get(MyReviewPos); MyRB.setRating((float) d); } catch (Exception e) { int d = (int) Rates.get(MyReviewPos); MyRB.setRating((float) d); } MyReviewTxt.setText((String) Reviews.get(MyReviewPos)); } return v; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.user_taxi_status); init(); bundle = getIntent().getExtras(); lat = Float.parseFloat(bundle.getString(SRC_LAT)); lng = Float.parseFloat(bundle.getString(SRC_LNG)); srcLatLng = new LatLng(lat, lng); lat = Float.parseFloat(bundle.getString(DIST_LAT)); lng = Float.parseFloat(bundle.getString(DIST_LNG)); distLatLng = new LatLng(lat, lng); driverName = bundle.getString(SELECTED_DRIVER_NAME); tvDrivername.setText(driverName); tvDriverMobile.setText(bundle.getString(SELECTED_DRIVER_MOBILE)); rating = Float.parseFloat(bundle.getString(SELECTED_DRIVER_RATING)); driverId = bundle.getString(SELECTED_DRIVER_ID); rbDriverRate.setRating(rating + 0.5f); rbDriverRate.setRating(rating); CustomMapFragmment customMapFragmment = (CustomMapFragmment) getFragmentManager().findFragmentById(R.id.map); customMapFragmment.setListener(this); customMapFragmment.getMapAsync(this); }
private void updateGradeViews() { getSupportActionBar().setTitle(mGrade.disc != null ? mGrade.disc : ""); getSupportActionBar() .setSubtitle( String.format( getResources().getQuantityString(R.plurals.avaliacoes, mGrade.nr_avaliations), mGrade.nr_avaliations)); if (mGrade.disc != null) { TextView tvGradeName = (TextView) findViewById(R.id.tv_grade_name); tvGradeName.setText( mGrade.disc + " - " + "(" + mGrade.T + "-" + mGrade.P + "-" + mGrade.I + ")"); } TextView tvGradeRecomendation = (TextView) findViewById(R.id.tv_grade_recomendation); tvGradeRecomendation.setText(mGrade.recommendation != null ? mGrade.recommendation : ""); TextView tvGradeMenu = (TextView) findViewById(R.id.tv_grade_menu); tvGradeMenu.setText(mGrade.menu != null ? mGrade.menu : ""); RatingBar ratingBarGradeExtraWork = (RatingBar) findViewById(R.id.rb_grade_amount_of_extra_work); ratingBarGradeExtraWork.setRating(mGrade.nr_works); TextView tvWorkAverage = (TextView) findViewById(R.id.tv_grade_amount_of_extra_work_average); tvWorkAverage.setText(getString(R.string.media_) + String.format("%.2f", mGrade.nr_works)); TextView tvWorkAmount = (TextView) findViewById(R.id.tv_grade_amount_of_extra_work_amount); tvWorkAmount.setText(getWorkAmount(mGrade.nr_works)); RatingBar ratingBarGradeDedication = (RatingBar) findViewById(R.id.rb_grade_required_dedication); ratingBarGradeDedication.setRating(mGrade.nr_dedication); TextView tvDedicationAverage = (TextView) findViewById(R.id.tv_grade_required_dedication_average); tvDedicationAverage.setText( getString(R.string.media_) + String.format("%.2f", mGrade.nr_dedication)); TextView tvDedicationNeeded = (TextView) findViewById(R.id.tv_grade_required_dedication_needed); tvDedicationNeeded.setText(getDedicationNeeded(mGrade.nr_dedication)); RatingBar ratingBarGradePrerequesites = (RatingBar) findViewById(R.id.rb_grade_prerequesites); ratingBarGradePrerequesites.setRating(mGrade.nr_requirements); TextView tvPrerequesitesAverage = (TextView) findViewById(R.id.tv_grade_prerequesites_average); tvPrerequesitesAverage.setText( getString(R.string.media_) + String.format("%.2f", mGrade.nr_requirements)); TextView tvPrerequesitesAmount = (TextView) findViewById(R.id.tv_grade_prerequesites_amount); tvPrerequesitesAmount.setText(getRequisitesAmount(mGrade.nr_requirements)); Typeface typeface = tvPrerequesitesAmount.getTypeface(); setupChart(typeface); }
@Override public View getView(int i, View view, ViewGroup group) { // TODO Auto-generated method stub if (view == null) { view = mInflater.inflate(R.layout.sleep_listview_item, null); } RatingBar ratingBar = (RatingBar) view.findViewById(R.id.listview_rb_score); TextView tv_sleeptime = (TextView) view.findViewById(R.id.listview_tv_sleeptime); TextView tv_deepsleep = (TextView) view.findViewById(R.id.listview_tv_deepsleep); TextView tv_lightsleep = (TextView) view.findViewById(R.id.listview_tv_lightsleep); TextView tv_waketime = (TextView) view.findViewById(R.id.listview_tv_waketime); TextView tv_wakenum = (TextView) view.findViewById(R.id.listview_tv_wakenum); // TextView tv_commit =(TextView)view.findViewById(R.id.listview_tv_commit); HashMap<String, String> hashMap = data_list.get(i); ratingBar.setRating((float) Double.parseDouble(hashMap.get("score"))); tv_sleeptime.setText("时长 " + hashMap.get("listview_tv_sleeptime")); tv_deepsleep.setText("深睡˯ " + hashMap.get("listview_tv_deepsleep")); tv_lightsleep.setText("浅睡 " + hashMap.get("listview_tv_lightsleep")); tv_waketime.setText("中断时长 " + hashMap.get("listview_tv_waketime")); tv_wakenum.setText("中断次数 " + hashMap.get("listview_tv_wakenum")); // tv_commit.setText(hashMap.get("listview_tv_commit")); return view; }
// ** Called when the activity is first created. *//* @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); // 隐藏标题 getWindow() .setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); // 设置全屏 nameHeaderUrlList = new ArrayList<NameHeaderUrlPair>(); if (apiKey == null || apiSecret == null) { Util.showAlert(this, "警告", "人人应用的apiKey和apiSecret必须提供!"); } setContentView(R.layout.main); ratingBar = (RatingBar) findViewById(R.id.levelBar); ratingBar.setMax(6); ratingBar.setNumStars(3); ratingBar.setStepSize((float) 0.5); ratingBar.setRating((float) 1.5); initialRenRen(); /*Spinner s = (Spinner) findViewById(R.id.friendNumerSpin); String []friendNumber=new String[]{"好友人数:10","好友人数:20","好友人数:50","所有好友"}; ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, friendNumber); s.setAdapter(adapter);*/ }
public IceTvMovieListItem(Context context, IceMovie theMovie, IceTvGuide guide) { super(context); this.theMovie = theMovie; this.guide = guide; LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); inflater.inflate(R.layout.icemovie, this, true); this.setOrientation(LinearLayout.HORIZONTAL); titleText = (TextView) findViewById(R.id.movie_view_title); dateTimeText = (TextView) findViewById(R.id.movie_view_datetime); stationText = (TextView) findViewById(R.id.movie_view_station); ratingBar = (RatingBar) findViewById(R.id.movie_view_rating); previewImage = (ImageView) findViewById(R.id.movie_view_image); SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy h:mmaa"); titleText.setText(theMovie.GetBaseMovieName()); dateTimeText.setText(formatter.format(theMovie.GetProgram().GetStart())); stationText.setText( guide.GetStationList().Get(theMovie.GetProgram().GetStation()).GetMainDisplayName()); ratingBar.setStepSize(0.1f); ratingBar.setNumStars(10); ratingBar.setRating((float) theMovie.GetRating()); previewImage.setImageBitmap(theMovie.GetImage()); }
/** * ************************************************************************************************* * void addDetails() * * <p>This method adds all of the recipe details from the query. * * <p>************************************************************************************************** */ public void addDetails() { seekBar.setMax((Integer.parseInt(servings) * 4) - 1); seekBar.setProgress(Integer.parseInt(servings) - 1); // log.d("RecipeView_addDetails image=", rawImage); txtRecipeName.setText(recipeName); txtAuthor.setText(author); txtNumReviews.setText(numRatings); txtIngredientList.setText(getIngredientList(ingredientArray)); // adding a number before each line in the directions String lines[] = cookingDirections.split("\\r?\\n"); String dir = ""; for (int i = 0; i < lines.length - 1; i++) { dir += Integer.toString(i + 1) + ". " + lines[i] + "\n\n"; } dir += Integer.toString(lines.length) + ". " + lines[lines.length - 1]; txtCookingDirections.setText(dir); txtCookTime.setText(cookTime); txtPrepTime.setText(prepTime); txtServings.setText(servings); if (hasImage == 1) imgLoader.DisplayImage(urlRoot + imageUrl, imgPicture); rtbRating.setRating(Float.valueOf(rating) / 2); }
@Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.edit_task_frag); name = (EditText) findViewById(R.id.edit_task_name); category = (Spinner) findViewById(R.id.spinner_txt); progress = (SeekBar) findViewById(R.id.seekBar1); rating = (RatingBar) findViewById(R.id.rating_task); saveButton = (Button) findViewById(R.id.save_btn); Intent intent = getIntent(); long idTask = intent.getLongExtra("idTask", 0); layer = new TaskLayer(getApplication()); currentTask = layer.GetTask(idTask); ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, getCategories()); category.setAdapter(spinnerAdapter); category.setSelection(safeLongToInt(currentTask.category.getId() - 1)); ; name.setText(currentTask.name); progress.setProgress(currentTask.progress); rating.setRating(currentTask.importance); }
@Override public void bindView(View view, Context context, Cursor cursor) { // Set the name of the bottle. TextView name = (TextView) view.findViewById(R.id.list_element_name); name.setText( cursor.getString(cursor.getColumnIndex(DatabaseContract.BottleTable.COLUMN_NAME_NAME))); name.setTypeface(Fonts.getFonts(context).chopinScript); // Set the vintage of the bottle. TextView vintage = (TextView) view.findViewById(R.id.list_element_vintage); vintage.setText( cursor.getString(cursor.getColumnIndex(DatabaseContract.BottleTable.COLUMN_NAME_VINTAGE))); // Set the mark of the bottle. RatingBar rating = (RatingBar) view.findViewById(R.id.list_element_mark); rating.setRating( cursor.getInt(cursor.getColumnIndex(DatabaseContract.BottleTable.COLUMN_NAME_MARK))); // Set the quantity of the bottle. TextView quantity = (TextView) view.findViewById(R.id.list_element_quantity); quantity.setText( Integer.toString( cursor.getInt( cursor.getColumnIndex(DatabaseContract.BottleTable.COLUMN_NAME_QUANTITY)))); }
public static void initializeRatingBar( @NonNull final Geocache cache, final View parentView, @Nullable final OnRatingChangeListener changeListener) { if (GCVote.isVotingPossible(cache)) { final RatingBar ratingBar = ButterKnife.findById(parentView, R.id.gcvoteRating); final TextView label = ButterKnife.findById(parentView, R.id.gcvoteLabel); ratingBar.setVisibility(View.VISIBLE); label.setVisibility(View.VISIBLE); ratingBar.setOnRatingBarChangeListener( new OnRatingBarChangeListener() { @Override public void onRatingChanged( final RatingBar ratingBar, final float stars, final boolean fromUser) { // 0.5 is not a valid rating, therefore we must limit final float rating = GCVote.isValidRating(stars) ? stars : 0; if (rating < stars) { ratingBar.setRating(rating); } label.setText(GCVote.getDescription(rating)); if (changeListener != null) { changeListener.onRatingChanged(rating); } } }); ratingBar.setRating(cache.getMyVote()); } }
private void updateStats() { StatisticsCalculator statCalculator = new StatisticsCalculator(getActivity()); DeckStatistics stats = statCalculator.getDeckStatistics(deckID); DecimalFormat df = new DecimalFormat("###.#"); tvCurrentWins.setText(String.valueOf(stats.getCurrentWins())); tvCurrentLosses.setText(String.valueOf(stats.getCurrentLosses())); tvCurrentWinPc.setText(String.valueOf(df.format(stats.getCurrentWinpc()))); tvTotalWins.setText(String.valueOf(stats.getTotalWins())); tvTotalLosses.setText(String.valueOf(stats.getTotalLosses())); tvTotalWinPc.setText(String.valueOf(df.format(stats.getTotalWinpc()))); // Version 3.6 // setMostCommonManaSymbol(imgCommonWin, stats.getCommonwin()); // setMostCommonManaSymbol(imgCommonLoss, stats.getCommonloss()); // Version 2.1 // slPerformanceRating.setProgress(stats.getPerformanceRating()); // slPerformanceRating.setEnabled(false); // Version 3.0 PerformanceRating performanceRating = new PerformanceRating(); performanceRating.setPerformanceRatingFromRaw(stats.getPerformanceRating()); rBarDeckPerformanceRating.setRating(performanceRating.getPerformanceRatingAsStars()); // Version 3.6 grWinrateHistory.drawGraph(stats.getWinrateHistory()); }
public RatingBar(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RatingBar, defStyle, 0); final int numStars = a.getInt(R.styleable.RatingBar_numStars, mNumStars); setIsIndicator(a.getBoolean(R.styleable.RatingBar_isIndicator, !mIsUserSeekable)); final float rating = a.getFloat(R.styleable.RatingBar_rating, -1); final float stepSize = a.getFloat(R.styleable.RatingBar_stepSize, -1); a.recycle(); if (numStars > 0 && numStars != mNumStars) { setNumStars(numStars); } if (stepSize >= 0) { setStepSize(stepSize); } else { setStepSize(0.5f); } if (rating >= 0) { setRating(rating); } // A touch inside a star fill up to that fractional area (slightly more // than 1 so boundaries round up). mTouchProgressOffset = 1.1f; }
@Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = LayoutInflater.from(this.getContext()) .inflate(R.layout.comentario_adapter, (ViewGroup) null); } ImageView fotoUsuarioListView = (ImageView) convertView.findViewById(R.id.fotoUsuarioListView); TextView comentarioUserNameTextView = (TextView) convertView.findViewById(R.id.comentarioUserNameTextView); TextView comentarioPreviewTextView = (TextView) convertView.findViewById(R.id.comentarioPreviewTextView); RatingBar comentarioPuntajeRatingBar = (RatingBar) convertView.findViewById(R.id.comentarioPuntajeRatingBar); Comentario comentario = this.getItem(position); Usuario usuario = this.usuarioService.getById(comentario.getUserId()); fotoUsuarioListView.setImageBitmap(BitmapUtility.getImage(usuario.getFoto())); comentarioUserNameTextView.setText(usuario.getUserName()); comentarioPreviewTextView.setText(comentario.getPreview()); comentarioPuntajeRatingBar.setRating(comentario.getPuntaje()); convertView.setBackgroundResource(R.color.default_color); return convertView; }
private boolean setRatingView(View view, Cursor cursor, int columnIndex) { RatingBar ratingBar = (RatingBar) view; int rating = cursor.getInt(columnIndex); ratingBar.setRating(rating / Constants.RATING_MULTIPLIER); return true; }
private void setupViews(View view) { mQuestionView = (TextView) view.findViewById(R.id.question); mRatingBar = (RatingBar) view.findViewById(R.id.ratingbar); mRatingBar.setOnRatingBarChangeListener( new RatingBar.OnRatingBarChangeListener() { @Override public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) { int ratingInt = (int) rating - 1; setQandA(ratingInt); if (!mInitializing) { mListener.onQuestionAnswered(mQuestion.getQuestionNumber(), ratingInt); mInitializing = false; } } }); mRatingBar.setOnTouchListener( new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { int ratingInt = (int) mRatingBar.getRating() - 1; setQandA(ratingInt); return false; } }); int persistedResponse = getArguments().getInt(KEY_PERSISTED_RESPONSE); if (persistedResponse > -1) { mInitializing = true; mRatingBar.setRating(persistedResponse + 1); } }
public View getView(int posicion, View vistaReciclada, ViewGroup padre) { Lugar lugar = Lugares.elemento(posicion); if (vistaReciclada == null) { vistaReciclada = inflador.inflate(R.layout.elemento_lista, null); } nombre = (TextView) vistaReciclada.findViewById(R.id.nombre); direccion = (TextView) vistaReciclada.findViewById(R.id.direccion); foto = (ImageView) vistaReciclada.findViewById(R.id.foto); valoracion = (RatingBar) vistaReciclada.findViewById(R.id.valoracion); nombre.setText(lugar.getNombre()); direccion.setText(lugar.getDireccion()); int id = R.drawable.otros; switch (lugar.getTipo()) { case RESTAURANTE: id = R.drawable.restaurante; break; case BAR: id = R.drawable.bar; break; case COPAS: id = R.drawable.copas; break; case ESPECTACULO: id = R.drawable.espectaculos; break; case HOTEL: id = R.drawable.hotel; break; case COMPRAS: id = R.drawable.compras; break; case EDUCACION: id = R.drawable.educacion; break; case DEPORTE: id = R.drawable.deporte; break; case NATURALEZA: id = R.drawable.naturaleza; break; case GASOLINERA: id = R.drawable.gasolinera; break; } foto.setImageResource(id); foto.setScaleType(ImageView.ScaleType.FIT_END); valoracion.setRating(lugar.getValoracion()); distancia = (TextView) vistaReciclada.findViewById(R.id.distancia); if (Lugares.posicionActual != null && lugar.getPosicion() != null) { int d = (int) Lugares.posicionActual.distancia(lugar.getPosicion()); if (d < 2000) { distancia.setText(d + " m"); } else { distancia.setText(d / 1000 + "Km"); } } return vistaReciclada; }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.facebook); // 필요한 위젯들 전부 로딩 faceBook_myTitleTxtVw = (TextView) findViewById(R.id.faceBook_movieTitle); faceBook_myWhenTxtVw = (TextView) findViewById(R.id.faceBook_myWhenTxtVw); faceBook_myWhereTxtVw = (TextView) findViewById(R.id.faceBook_myWhereTxtVw); faceBook_myWithTxtVw = (TextView) findViewById(R.id.faceBook_myWhoTxtVw); faceBook_myGenreTxtVw = (TextView) findViewById(R.id.faceBook_myGenreTxtVw); faceBook_myOpenInfoTxtVw = (TextView) findViewById(R.id.faceBook_myOpenInfoTxtVw); faceBook_myActorTxtVw = (TextView) findViewById(R.id.faceBook_myActorTxtVw); faceBook_myDirectorTxtVw = (TextView) findViewById(R.id.faceBook_myDirectorTxtVw); faceBook_myThumbnail = (ImageView) findViewById(R.id.faceBook_myThumbnail); faceBook_myRatingBar = (RatingBar) findViewById(R.id.faceBook_myRatingBar); // 전달받은 인텐트를 가져온다. Intent intent = getIntent(); // 인텐트가 존재하면 if (intent != null) { // movie객체를 가져와서 데이터를 뿌려준다. Movie movie = (Movie) intent.getSerializableExtra("movie"); this.movie = movie; faceBook_myTitleTxtVw.setText(movie.getTitle()); String getWhen = movie.getWhen(); String year = getWhen.substring(0, 4); String month = getWhen.substring(4, 5); String day = getWhen.substring(5, 7); faceBook_myWhenTxtVw.setText(year + "년 " + month + "월 " + day + "일"); faceBook_myWithTxtVw.setText(movie.getWith()); faceBook_myWhereTxtVw.setText(movie.getWhere()); rating = (float) ((movie.getGrade().equals("")) ? 0.0 : Float.parseFloat(movie.getGrade())) / (float) 2.0; faceBook_myRatingBar.setRating(rating); faceBook_myGenreTxtVw.setText(" ● 장르 : " + movie.getGenre()); faceBook_myActorTxtVw.setText(" ● 감독 : " + movie.getDirector()); faceBook_myActorTxtVw.setText(" ● 배우 : " + Arrays.toString(movie.getActor())); faceBook_myOpenInfoTxtVw.setText(" ● 개봉일 : " + movie.getOpenInfo()); imageDownloader.download(movie.getThumbnail(), faceBook_myThumbnail); } mEtContent = (EditText) findViewById(R.id.faceBook_etContent); mBtnFeed = (Button) findViewById(R.id.faceBook_btnFeed); mBtnFeed.setOnClickListener(this); faceBook_btnLogout = (Button) findViewById(R.id.faceBook_btnLogout); faceBook_btnLogout.setOnClickListener(this); mFacebookAccessToken = getAppPreferences(this, "ACCESS_TOKEN"); if (!mFacebookAccessToken.equals("")) { mFacebook.setAccessToken(mFacebookAccessToken); } }
/** 初始化 */ public void setupViews() { intent = getIntent(); mAppId = intent.getIntExtra("app_id", 0); // 获取对应app 的ID mAmount = intent.getIntExtra("amount", 0); // 评论人数 mUserID = intent.getStringExtra("user_id"); // 用户id mHaveBeenEvaluated = intent.getBooleanExtra("isScore", false); // 获取是否评分 mScoreValue = intent.getFloatExtra("ScoreValue", 0); // 获取已评分数 if ("-1".equals(mUserID)) { // 祥情里没获取userid,则默认此时已评价(不提交评分信息) mHaveBeenEvaluated = true; } mRatingBar = (RatingBar) findViewById(R.id.ratingBar); bar = (LinearLayout) findViewById(R.id.bar); mRatingBarText = (TextView) findViewById(R.id.text); animationDrawable = (AnimationDrawable) bar.getBackground(); mCloseButton = (ImageButton) findViewById(R.id.close); mTextView1 = (TextView) findViewById(R.id.text_1); // 已有多少人评价 mTextView2 = (TextView) findViewById(R.id.text_2); // 使用说明 mRatingBar.setRating(mScoreValue); mRatingBar.setOnRatingBarChangeListener(new RatingBarListener()); // if(mHaveBeenEvaluated){ //已评价 // evaluated(); // //mRatingBar.setFocusable(false);//让星星失去焦点 // AppLog.d(TAG,"-------------------------id--"+mAppId +"--已评价----------------"); // }else{ // mRatingBar.setRating(mScoreValue); // mRatingBar.setOnRatingBarChangeListener(new RatingBarListener()); // AppLog.d(TAG,"-------------------------id--"+mAppId +"--未评价----------------"); // } // 每次都让评价 // mRatingBar.setOnRatingBarChangeListener(new RatingBarListener()); mCloseButton.setOnClickListener( new OnClickListener() { public void onClick(View v) { if (v.getId() == R.id.close) { finish(); } } }); setCloseFocuseChange(mCloseButton); mRatingBar.requestFocus(); animationDrawable.start(); mRatingBar.setOnClickListener( new OnClickListener() { public void onClick(View v) { mIsSuer = true; mTextView1.setText( AppAppraisalActivity.this.getString(R.string.app_appraisal_text1, mAmount + 1)); handler.sendEmptyMessageDelayed(CLOSE, 700); } }); setBarFocuseChange(mRatingBar); }
/** * Creates and adds a control that shows a review rating score. * * @param rating Fractional rating out of 5 stars. */ public View addRatingBar(float rating) { View ratingLayout = LayoutInflater.from(getContext()).inflate(R.layout.infobar_control_rating, this, false); addView(ratingLayout, new ControlLayoutParams()); RatingBar ratingView = (RatingBar) ratingLayout.findViewById(R.id.control_rating); ratingView.setRating(rating); return ratingView; }
// @SuppressLint("NewApi") @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_my_recipe); // getting intent data Intent in = getIntent(); // Get JSON values from previous intent String nameLabel = in.getStringExtra(TAG_RECIPENAME); String ratingLabel = in.getStringExtra(TAG_RATING); String idLabel = in.getStringExtra(TAG_ID); int ratingValue = Integer.parseInt(ratingLabel); Log.d("RATING VALUE", "" + ratingValue); getUrl = getUrl + idLabel + "?_app_id=150f3a36&_app_key=e2476f53e6b5deead0a8189f45365986"; if (isConnected()) { Log.d("YAAAAY", "connected"); } else { Log.d("NOOOOO", "not connected"); } new HttpAsyncTask().execute(getUrl); // Displaying all values on the screen TextView lblName = (TextView) findViewById(R.id.recipeName_label); lblName.setText(nameLabel); int val = Integer.parseInt(ratingLabel); facebook = new Facebook(APP_ID); mAsyncRunner = new AsyncFacebookRunner(facebook); ratingBar = (RatingBar) findViewById(R.id.ratingBar); ratingBar.setRating(val); urlButton = (Button) findViewById(R.id.sourceurl_label); logout = (Button) findViewById(R.id.logout_button); share = (ImageButton) findViewById(R.id.share_recipe); /** Logout button Click event */ /*logout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.d("Logout", "button Clicked"); facebookLogout(); } }); */ }
public void setRating(float rating) { this.rating = rating; if (rating == 0) { ratingBar.setVisibility(GONE); ratingTv.setText(R.string.label_no_rating); } else { ratingBar.setRating(rating / 2); ratingBar.setVisibility(VISIBLE); ratingTv.setText("" + rating); } }
public void editMovie(int mID, String mTitle) { LinearLayout viewGroup = (LinearLayout) findViewById(R.id.popupLinearLayout); LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); editMovieLayout = layoutInflater.inflate(R.layout.edit_movie, viewGroup); selectedMovie = db.getMovie(mID); int popupDimensions = WindowManager.LayoutParams.MATCH_PARENT; TextView mName = (TextView) editMovieLayout.findViewById(R.id.editMovieName); mName.setText(mTitle); final RatingBar mRating = (RatingBar) editMovieLayout.findViewById(R.id.editRating); mRating.setRating(selectedMovie.getRating()); // Creating the PopupWindow final PopupWindow popup = new PopupWindow(); popup.setContentView(editMovieLayout); popup.setWidth(popupDimensions); popup.setHeight(popupDimensions); popup.setFocusable(true); // popup.setAnimationStyle(R.style.PopupWindowAnimation); // Displaying the popup at the specified location, + offsets. popup.showAtLocation(editMovieLayout, Gravity.CENTER, 0, 0); ImageButton close = (ImageButton) editMovieLayout.findViewById(R.id.close); close.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { popup.dismiss(); } }); Button save = (Button) editMovieLayout.findViewById(R.id.saveMovieButton); save.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { selectedMovie.setRating(mRating.getRating()); db.updateMovie(selectedMovie); try { populateMyMovies(lv); } catch (ParseException e) { e.printStackTrace(); } popup.dismiss(); } }); }
protected void onPostExecute(String result) { try { RatingBar rating = (RatingBar) findViewById(R.id.rating_bar_set); jsonResult = (JSONArray) new JSONParser().parse(result); jsonObj = (JSONObject) jsonResult.get(0); if (jsonObj.get("Average") == null) { rating.setRating(0); } else { String resultStr = (String) jsonObj.get("Average"); Log.i("OnPost - String", resultStr); int resultInt = (int) (Math.round(Double.parseDouble(resultStr))); Log.i("OnPost - Int", Integer.toString(resultInt)); rating.setRating(resultInt); } } catch (Exception e) { Log.i("OnPost", "Error point 1"); } }
public void setForm(Student studentForm) { firstNameField.setText(studentForm.getFirstName()); lastNameField.setText(studentForm.getLastName()); nicknameField.setText(studentForm.getNickname()); addressField.setText(studentForm.getAddress()); phoneField.setText(studentForm.getPhone()); websiteField.setText(studentForm.getWebsite()); ratingField.setRating(Float.valueOf(studentForm.getRate().toString())); student = studentForm; }
private void addFeedback(final String username) { Log.d("TarotFeedback", "username :: " + username); View dialogLayout = LayoutInflater.from(this).inflate(R.layout.feedback_alert_dialog, null); AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AppCompatAlertDialogStyle); builder.setView(dialogLayout); EditText usernameEditText = (EditText) dialogLayout.findViewById(R.id.user_edittext); usernameEditText.setText(username); final CommentEditText commentEditText = (CommentEditText) dialogLayout.findViewById(R.id.feedback_edittext); final RatingBar feedbackRating = (RatingBar) dialogLayout.findViewById(R.id.rating); final AlertDialog customAlertDialog = builder.create(); final Button saveButton = (Button) dialogLayout.findViewById(R.id.feedback_button); final Feedback feedbackFromPreference = readFromPreference(); commentEditText.setText(feedbackFromPreference.getFeedback()); feedbackRating.setRating((float) feedbackFromPreference.getRating()); if (!TextUtils.isEmpty(feedbackFromPreference.getObjectId())) { saveButton.setText(R.string.update_button_label); } saveButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { String comment = commentEditText.getText().toString(); String user = username; float rating = feedbackRating.getRating(); if (TextUtils.isEmpty(comment)) { Toast.makeText( TarotFeedbackActivity.this, getString(R.string.save_error_2), Toast.LENGTH_SHORT) .show(); return; } if (rating == 0.0f) { Toast.makeText( TarotFeedbackActivity.this, getString(R.string.save_error_1), Toast.LENGTH_SHORT) .show(); return; } submitFeedback( comment, user, rating, feedbackFromPreference.getObjectId(), customAlertDialog); } }); customAlertDialog.show(); }
protected void update() { if (moreButton != null) { if (exists || pinned) { if (!shaded) { moreButton.setImageResource( exists ? R.drawable.download_cached : R.drawable.download_pinned); shaded = true; } } else { if (shaded) { moreButton.setImageResource(DrawableTint.getDrawableRes(context, R.attr.download_none)); shaded = false; } } } if (starButton != null) { if (isStarred) { if (!starred) { if (starButton.getDrawable() == null) { starButton.setImageDrawable( DrawableTint.getTintedDrawable(context, R.drawable.ic_toggle_star)); } starButton.setVisibility(View.VISIBLE); starred = true; } } else { if (starred) { starButton.setVisibility(View.GONE); starred = false; } } } if (ratingBar != null && isRated != rating) { if (isRated > 0 && rating == 0) { ratingBar.setVisibility(View.VISIBLE); } else if (isRated == 0 && rating > 0) { ratingBar.setVisibility(View.GONE); } ratingBar.setRating(isRated); rating = isRated; } if (coverArtView != null && coverArtView instanceof RecyclingImageView) { RecyclingImageView recyclingImageView = (RecyclingImageView) coverArtView; if (recyclingImageView.isInvalidated()) { onUpdateImageView(); } } }
public View getView(int position, View convertView, ViewGroup parent) { ViewWrapper wrap = null; View row = convertView; if (convertView == null) { LinearLayout layout = new LinearLayout(ctxt); RatingBar rate = new RatingBar(ctxt); rate.setNumStars(3); rate.setStepSize(1.0f); View guts = delegate.getView(position, null, parent); layout.setOrientation(LinearLayout.HORIZONTAL); rate.setLayoutParams( new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.FILL_PARENT)); guts.setLayoutParams( new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT)); RatingBar.OnRatingBarChangeListener l = new RatingBar.OnRatingBarChangeListener() { public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromTouch) { rates[(Integer) ratingBar.getTag()] = rating; } }; rate.setOnRatingBarChangeListener(l); layout.addView(rate); layout.addView(guts); wrap = new ViewWrapper(layout); wrap.setGuts(guts); layout.setTag(wrap); rate.setTag(new Integer(position)); rate.setRating(rates[position]); row = layout; } else { wrap = (ViewWrapper) convertView.getTag(); wrap.setGuts(delegate.getView(position, wrap.getGuts(), parent)); wrap.getRatingBar().setTag(new Integer(position)); wrap.getRatingBar().setRating(rates[position]); } return (row); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.movie_detail_view); // Get intent data Intent i = getIntent(); // Selected image id // int position = i.getExtras().getInt("id"); String InstanceTagLocal = getApplicationContext().getResources().getString(R.string.InstanceTag2); Film recdFilm = i.getParcelableExtra(InstanceTagLocal); /* decide the heights of the controls on the basis of the displayMetrics */ final DisplayMetrics displayMetrics = new DisplayMetrics(); this.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); final int HeightLocal = displayMetrics.heightPixels; // final int WidthLocal = displayMetrics.widthPixels; ImageView imageView = (ImageView) findViewById(R.id.MovieDetailView); imageView.setMaxHeight((int) Math.round(HeightLocal * 0.30)); // Film film = imageAdapter.getInstance().films.get(position); // imageView.setImageResource(film.getPosterPath()); Glide.with(this) .load(baseImgURL + recdFilm.getPosterPath()) .error(R.drawable.big_problem) .into(imageView); TextView title = (TextView) findViewById(R.id.MovieTitle); title.setHeight((int) Math.round(HeightLocal * 0.20)); title.setText(recdFilm.getTitle()); RatingBar rating = (RatingBar) findViewById(R.id.UserRating); // float f = Float.parseFloat( film.getRating().trim() ); rating.setRating(recdFilm.getRating()); TextView releaseDate = (TextView) findViewById(R.id.ReleaseDate); releaseDate.setText( getApplicationContext().getResources().getString(R.string.ReleaseDateLabel) + recdFilm.getFormattedDate()); TextView overView = (TextView) findViewById(R.id.OverView); overView.setHeight((int) Math.round(HeightLocal * 0.30)); overView.setText(recdFilm.getOverview()); }
public void setStoreData(Shop data) { mData = data; storeNameView.setText(data.getShop_name()); storeDescriptionView.setText(data.getShop_intro()); storeDistanceView.setText(data.getDist() + "M"); if (data.getLiked() == 0) { buttonLike.setBackgroundResource(R.drawable.btn_nm008_like_off); } else if (data.getLiked() == 1) { buttonLike.setBackgroundResource(R.drawable.btn_nm008_like_on); } shoplistRatingbar.setRating((float) data.getShop_score()); Glide.with(storeImageView.getContext()).load(data.getShop_pic()).into(storeImageView); }
@Override public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View row = inflater.inflate(R.layout.activity_driverrowlistview, parent, false); String[] items = getResources().getStringArray(R.array.Drivers); ImageView iv = (ImageView) row.findViewById(R.id.listdriverimage); TextView tv = (TextView) row.findViewById(R.id.listdrivername); RatingBar rt = (RatingBar) row.findViewById(R.id.ratingBar); tv.setText(items[position]); // rt.setNumStars(3); // rt.setRating(3); if (items[position].equals("Chathura")) { iv.setImageResource(R.drawable.chathura); rt.setRating((float) 4.5); } else if (items[position].equals("Kasun")) { iv.setImageResource(R.drawable.kasun); rt.setRating((float) 3.5); } else if (items[position].equals("Sanath")) { iv.setImageResource(R.drawable.sanath_peris2); rt.setRating((float) 3); } else if (items[position].equals("Suminda")) { iv.setImageResource(R.drawable.suminda); rt.setRating((float) 2.5); } else if (items[position].equals("Kapila")) { iv.setImageResource(R.drawable.kapila); rt.setRating((float) 2); } return row; // tv.setText(items[position]); }