public void add_car(int x, int y, int rotation, int state) { ImageView car = new ImageView(getActivity()); carList.add(car); switch (state) { case 0: car.setBackground(getResources().getDrawable(R.drawable.ic_launcher0)); break; case 1: car.setBackground(getResources().getDrawable(R.drawable.ic_launcher1)); break; case 2: car.setBackground(getResources().getDrawable(R.drawable.ic_launcher2)); break; default: break; } RelativeLayout.LayoutParams layoutParams = new LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); layoutParams.setMargins(x, y, 10, 10); // 150-1650/50-950 car.setRotation(rotation); layout.addView(car, layoutParams); }
private void showImg() { life_img01.setBackground(null); life_img02.setBackground(null); life_img03.setBackground(null); life_img04.setBackground(null); city_num = (int) WeatherHelper.getCurrentCity(1).get("cityIndex"); Log.d("iii", "clothes_color : " + list.get(city_num).clothes_color); Log.d("iii", "car_color : " + list.get(city_num).car_color); Log.d("iii", "outdoor_color : " + list.get(city_num).outdoor_color); Log.d("iii", "Clothesline_color : " + list.get(city_num).Clothesline_color); if (list.get(city_num).clothes_color.equals("1")) { life_img01.setBackgroundResource(R.drawable.weather_03_o_green); } else if (list.get(city_num).clothes_color.equals("2")) { life_img01.setBackgroundResource(R.drawable.weather_03_o_yellow); } else if (list.get(city_num).clothes_color.equals("3")) { life_img01.setBackgroundResource(R.drawable.weather_03_o_red); } else { } if (list.get(city_num).car_color.equals("1")) { life_img02.setBackgroundResource(R.drawable.weather_03_o_green); } else if (list.get(city_num).car_color.equals("2")) { life_img02.setBackgroundResource(R.drawable.weather_03_o_yellow); } else if (list.get(city_num).car_color.equals("3")) { life_img02.setBackgroundResource(R.drawable.weather_03_o_red); } else { } if (list.get(city_num).outdoor_color.equals("1")) { life_img03.setBackgroundResource(R.drawable.weather_03_o_green); } else if (list.get(city_num).outdoor_color.equals("2")) { life_img03.setBackgroundResource(R.drawable.weather_03_o_yellow); } else if (list.get(city_num).outdoor_color.equals("3")) { life_img03.setBackgroundResource(R.drawable.weather_03_o_red); } else { } if (list.get(city_num).Clothesline_color.equals("1")) { life_img04.setBackgroundResource(R.drawable.weather_03_o_green); } else if (list.get(city_num).Clothesline_color.equals("2")) { life_img04.setBackgroundResource(R.drawable.weather_03_o_yellow); } else if (list.get(city_num).Clothesline_color.equals("3")) { life_img04.setBackgroundResource(R.drawable.weather_03_o_red); } else { } }
// for setting image as a background @SuppressLint("NewApi") public void DisplayImage(String url, ImageView imageView) { if (null != url) url.replace("\\", ""); Log.e("URL", url); // Store image and url in Map imageViews.put(imageView, url); // Check image is stored in MemoryCache Map or not (see MemoryCache.java) Bitmap bitmap = memoryCache.get(url); if (bitmap != null) { // if image is stored in MemoryCache Map then // Show image in listview row BitmapDrawable bitmapDrawable = new BitmapDrawable(null, bitmap); Drawable drawable = (Drawable) bitmapDrawable; if (Build.VERSION.SDK_INT >= 4.0) { imageView.setBackgroundDrawable(drawable); // this code will be executed on devices running on DONUT (NOT ICS) or later } else imageView.setBackground(drawable); // imageView.setImageBitmap(bitmap); } else { // queue Photo to download from url queuePhoto(url, imageView); // Before downloading image show default image // imageView.setImageResource(stub_id); } }
@Override public View getDropDownView( int position, View convertView, ViewGroup parent) { // This view starts when we click the spinner. View row = convertView; if (row == null) { LayoutInflater inflater = context.getLayoutInflater(); row = inflater.inflate(R.layout.spinner_row_my_children, parent, false); } PatientChildData item = spinnerItems.get(position); if (item != null) { // Parse the data from each object and set it. TextView myChildName = (TextView) row.findViewById(R.id.spinnerTxtTitle); ImageView patientPhoto = (ImageView) row.findViewById(R.id.patientPhoto); if (myChildName != null) myChildName.setText(item.getFirtname() + " " + item.getLastname()); byte[] childPhotoData = item.getPatientphoto(); if (childPhotoData != null) { Log.d("ROBERT BTE", childPhotoData.length + ""); Bitmap bMap = BitmapFactory.decodeByteArray(childPhotoData, 0, childPhotoData.length); patientPhoto.setBackground(Utils.resizedBitmapDisplayPatientQueue(context, bMap)); } } return row; }
public void onReceive(Context context, Intent intent) { String action = intent.getAction(); bluetoothImage.setBackgroundResource(R.drawable.discovering_animation); anim = (AnimationDrawable) bluetoothImage.getBackground(); if (BluetoothAdapter.ACTION_DISCOVERY_STARTED.equals(action)) { discoverBT.setText(R.string.cancel_discovery); enableBT.setEnabled(false); checkBT.setEnabled(false); anim.start(); Toast.makeText(MainActivity.this, R.string.discovering, Toast.LENGTH_SHORT).show(); } else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) { discoverBT.setText(R.string.discover_devices); enableBT.setEnabled(true); checkBT.setEnabled(true); anim.stop(); bluetoothImage.setBackground(getResources().getDrawable((R.drawable.btooth_on))); Toast.makeText(MainActivity.this, R.string.discovery_finished, Toast.LENGTH_SHORT) .show(); } else if (BluetoothDevice.ACTION_FOUND.equals(action)) { BluetoothDevice device = (BluetoothDevice) intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); if (!tmpBtChecker.contains(device)) { tmpBtChecker.add(device); discoveredDevicesArList.add(device.getName() + "\n" + device.getAddress()); adapterForDiscoveredDevices.notifyDataSetChanged(); } } }
@Override protected void initView() { new TitleManager(AccountSecurityActivity.this, getString(R.string.account_security), 2) .getTitleRightView() .setVisibility(View.INVISIBLE); if (AppTools.PSWLV.equals("1")) psw_lv.setBackgroundResource(R.drawable.img_my_security_low); else if (AppTools.PSWLV.equals("2")) psw_lv.setBackgroundResource(R.drawable.img_my_security_middle); else if (AppTools.PSWLV.equals("3")) psw_lv.setBackgroundResource(R.drawable.img_my_security_high); else psw_lv.setBackground(null); if (AppTools.TEL.equals("")) { tel_txt.setTextColor(getResources().getColor(R.color.light_red)); tel_txt.setText(getString(R.string.account_unbounded)); binding_tel_layout.setOnClickListener(this); } else { tel_txt.setTextColor(getResources().getColor(R.color.lightgrey)); tel_txt.setText(Toolkit.getPhoneUserName(AppTools.TEL)); } if (AppTools.EMAIL.equals("")) { email_txt.setTextColor(getResources().getColor(R.color.light_red)); email_txt.setText(getString(R.string.account_unbounded)); binding_email_layout.setOnClickListener(this); } else { email_txt.setTextColor(getResources().getColor(R.color.lightgrey)); email_txt.setText(Toolkit.getMailUserName(AppTools.EMAIL)); } }
public void setForground(Drawable d) { int sdk = android.os.Build.VERSION.SDK_INT; if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) { forground.setBackgroundDrawable(d); } else { forground.setBackground(d); } }
public void setDrawableIcon(Drawable drawableIcon) { this.drawableIcon = drawableIcon; try { icon.setBackground(drawableIcon); } catch (NoSuchMethodError e) { icon.setBackgroundDrawable(drawableIcon); } }
public void setBackground(Drawable drawable) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { super.setBackground(drawable); } else { //noinspection deprecation setBackgroundDrawable(drawable); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ImageView button = (ImageView) findViewById(R.id.image); InputStream resource = getResources().openRawResource(R.drawable.dog); Bitmap bitmap = BitmapFactory.decodeStream(resource); button.setBackground(new MyRoundCornerDrawable(bitmap)); }
@Override public void setBackground(Drawable d) { int sdk = android.os.Build.VERSION.SDK_INT; if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) { background.setBackgroundDrawable(d); } else { background.setBackground(d); } background.setScaleType(ImageView.ScaleType.FIT_XY); }
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) @Override public void onClick(View v) { switch (v.getId()) { case R.id.like_icon: if (isNotLike) { if (isNumeric(likeNumber.getText().toString())) { likeIcon.setBackground(getContext().getResources().getDrawable(R.mipmap.like)); if ((Integer.parseInt(likeNumber.getText().toString()) - 1) > 0) { likeNumber.setText( String.valueOf(Integer.parseInt(likeNumber.getText().toString()) - 1)); } else if ((Integer.parseInt(likeNumber.getText().toString()) - 1) == 0) { likeNumber.setText("点赞"); } isNotLike = false; HashMap<Integer, Boolean> hashMap = new HashMap<>(); hashMap.put(getAdapterPosition(), isNotLike); SubCommentAdapter.isNotLike.get(data.getCid()).add(getAdapterPosition(), hashMap); } } else { if (isNumeric(likeNumber.getText().toString())) { likeNumber.setText( String.valueOf(Integer.parseInt(likeNumber.getText().toString()) + 1)); } else { likeNumber.setText("1"); } likeIcon.setBackground(getContext().getResources().getDrawable(R.mipmap.like_click)); isNotLike = true; HashMap<Integer, Boolean> hashMap = new HashMap<>(); hashMap.put(getAdapterPosition(), isNotLike); SubCommentAdapter.isNotLike.get(data.getCid()).add(getAdapterPosition(), hashMap); } if (isNumeric(likeNumber.getText().toString())) { updateSubLikes(Integer.parseInt(likeNumber.getText().toString()), isNotLike); } else { updateSubLikes(0, isNotLike); } break; } }
private void refreshView() { nickname.setText(info.getNickname()); email.setText(info.getEmail()); work.setText(info.getWork()); sign.setText(info.getUsersign()); birth.setText(info.getBirth()); followNum.setText(Integer.toString(info.getFollow_num())); focusNum.setText(Integer.toString(info.getFocus_num())); // btnFollow.setChecked(true); if (info.getSex().equals("0")) { sex.setBackground(getResources().getDrawable(R.drawable.ic_sex_boy)); } else { sex.setBackground(getResources().getDrawable(R.drawable.ic_sex_girl)); } location.setText(info.getLocation()); Picasso.with(UserInfoActivity.this) .load(StringUtils.getPicUrlList(info.getImg_url()).get(0)) .resize(200, 200) .centerCrop() .into(avatar); }
public void checkBT() { if (mBluetoothAdapter != null) { if (!mBluetoothAdapter.isEnabled()) { enableBT.setText(R.string.enable_bt); bluetoothImage.setBackground(getResources().getDrawable((R.drawable.btooth_off))); pairedDevicesTg.setEnabled(false); discoverBT.setEnabled(false); if (pairedDevicesTg.isChecked()) pairedDevicesTg.toggle(); discoveredDevicesArList.clear(); tmpBtChecker.clear(); adapterForDiscoveredDevices.notifyDataSetChanged(); } else { enableBT.setText(R.string.disable_bt); bluetoothImage.setBackground(getResources().getDrawable((R.drawable.btooth_on))); pairedDevicesTg.setEnabled(true); discoverBT.setEnabled(true); } } else { enableBT.setText(R.string.no_bt_found_button); bluetoothImage.setBackground(getResources().getDrawable((R.drawable.btooth_not_found))); pairedDevicesTg.setEnabled(false); } }
@Override public View getView(int position, View convertView, ViewGroup parent) { PatientChildData current = spinnerItems.get(position); LayoutInflater inflater = context.getLayoutInflater(); View row = inflater.inflate(R.layout.spinner_row_my_children_photo, parent, false); ImageView patientPhoto = (ImageView) row.findViewById(R.id.patientPhoto); byte[] childPhotoData = current.getPatientphoto(); if (childPhotoData != null) { Bitmap bMap = BitmapFactory.decodeByteArray(childPhotoData, 0, childPhotoData.length); patientPhoto.setBackground(Utils.resizedBitmapDisplayPatientQueue(context, bMap)); } return row; }
protected void onPostExecute(byte[] result) { if (result.length > 0) { try { Bitmap bmp = BitmapFactory.decodeByteArray(result, 0, result.length); if (bmp != null) { image.setBackground(null); image.setImageBitmap(bmp); } } catch (Exception e) { Log.e("", e.getMessage()); } } else { ImageView image = (ImageView) findViewById(R.id.profile_img); image.setBackgroundResource(R.drawable.icon_only_dark_crop); } }
public void setUpFriendListPage() { if (utils.getProfilePic() != null) { profileImage.setBackground(utils.getProfilePic()); } else { profileImage.setBackgroundResource(R.mipmap.fb_logo); } profileImage.setVisibility(View.VISIBLE); userInfo.setVisibility(View.VISIBLE); backButtons.setVisibility(View.VISIBLE); btnSyncContacts.setVisibility(View.INVISIBLE); logo.setVisibility(View.INVISIBLE); info.setVisibility(View.INVISIBLE); orText.setVisibility(View.INVISIBLE); loginButton.setVisibility(View.INVISIBLE); // TODO display friend list }
private void initView() { type = getIntent().getExtras().getInt(TYPE); info.setId(getIntent().getExtras().getInt(USER_ID)); nickname.setText(""); email.setText(""); work.setText(""); sign.setText(""); birth.setText(""); sex.setBackground(getResources().getDrawable(R.drawable.ic_sex_boy)); location.setText(""); followNum.setText(""); focusNum.setText(""); DataPresenter.requestUserInfoById(info.getId(), UserInfoActivity.this); if (type == TYPE_CURR_USER) { currUserFab.setVisibility(View.VISIBLE); btnFollow.setVisibility(View.GONE); } else if (type == TYPE_OTHER_USER) { otherUserFab.setVisibility(View.VISIBLE); btnFollow.setVisibility(View.VISIBLE); DataPresenter.requestFriendList(info.getId(), UserInfoActivity.this); } currUserFab.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { EditUserInfoActivity.actionStart(UserInfoActivity.this); } }); otherUserFab.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { MessageActivity.actionStart(UserInfoActivity.this, info.getUsername()); } }); }
private void setupStatusImageView() { float fillPercent = 0.8f; int inPlayOuter = getResources().getColor(R.color.blue_grey_300); int inPlayInner = getResources().getColor(R.color.blue_grey_600); mStatusImageDrawable = new LevelListDrawable(); mStatusImageDrawable.addLevel( 0, IN_PLAY_LEVEL, new ConcentricCirclesDrawable(new int[] {inPlayOuter, inPlayInner}, fillPercent)); mStatusImageDrawable.addLevel( 0, WON_LEVEL, new ConcentricCirclesDrawable(new int[] {Color.GREEN, Color.YELLOW}, fillPercent)); mStatusImageDrawable.addLevel( 0, LOST_LEVEL, new ConcentricCirclesDrawable(new int[] {Color.RED, Color.BLACK}, fillPercent)); mStatusImageView.setBackground(mStatusImageDrawable); }
@Override public void handleMessage(android.os.Message msg) { switch (msg.what) { case setpostphoto: Drawable photo = new BitmapDrawable(postphoto); selectphotoIV.setVisibility(View.INVISIBLE); if (postphotoIV == null) { Log.d("postphotoIV________", "postphotoIV null"); return; } postphotoIV.setBackground(photo); postphotoIV.setVisibility(View.VISIBLE); break; case intent: isSendPhoto = false; Intent intent = new Intent(SendPostActivity.this, PublicActivity.class); startActivity(intent); finish(); } }
@Override public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View row = inflater.inflate(R.layout.album_row_layout, parent, false); Typeface tf = Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-Thin.ttf"); TextView albumTitle = (TextView) row.findViewById(R.id.album_title); albumTitle.setTypeface(tf); albumTitle.setText(albums.get(position).getTitle()); TextView albumYear = (TextView) row.findViewById(R.id.album_year); albumYear.setTypeface(tf); albumYear.setText(albums.get(position).getYear()); ImageView albumThumb = (ImageView) row.findViewById(R.id.album_thumb); albumThumb.setBackground(albums.get(position).getAlbumArtDrawable()); row.setTag(albums.get(position)); return row; }
// Updates the txt in the tables @TargetApi(Build.VERSION_CODES.JELLY_BEAN) public void updateTable() { int gunsLvl = database.getLvl("guns"); superHack(); int engineLvl = database.getLvl("engine"); int shieldLvl = database.getLvl("shield"); // Sets the value of all the properties TextView cashTxt = (TextView) findViewById(R.id.cashTxt); cashTxt.setText("" + database.getCash()); // Sets the price of all the upgrades // If the price is -1, the sound is either at max level, or not // enough money to buy upgrade, sets text accordingly TextView gunsPrice = (TextView) findViewById(R.id.gunsPrice); if (database.getPrice("guns") != -1) { gunsPrice.setText("" + database.getPrice("guns")); } else { gunsPrice.setText("Maxed out!"); } TextView enginePrice = (TextView) findViewById(R.id.enginePrice); if (database.getPrice("engine") != -1) { enginePrice.setText("" + database.getPrice("engine")); } else { enginePrice.setText("Maxed out!"); } TextView shieldPrice = (TextView) findViewById(R.id.shieldPrice); if (database.getPrice("shield") != -1) { shieldPrice.setText("" + database.getPrice("shield")); } else { shieldPrice.setText("Maxed out!"); } // Initiate buttons Button gunsBtn = (Button) findViewById(R.id.gunsBtn); Button shieldBtn = (Button) findViewById(R.id.shieldBtn); Button engineBtn = (Button) findViewById(R.id.engineBtn); Button backBtn = (Button) findViewById(R.id.backBtn); Button resetBtn = (Button) findViewById(R.id.resetBtn); Button yesBtn = (Button) findViewById(R.id.yesBtn); Button noBtn = (Button) findViewById(R.id.noBtn); // If there is not enough cash or reached max level, make the button red if (!database.enoughCash("guns") || database.getLvl("guns") >= 5) { gunsBtn.setBackground(getResources().getDrawable(R.drawable.btn_buy_no)); } else { gunsBtn.setBackground(getResources().getDrawable(R.drawable.btn_buy_xml)); } if (!database.enoughCash("engine") || database.getLvl("engine") >= 5) { engineBtn.setBackground(getResources().getDrawable(R.drawable.btn_buy_no)); } else { engineBtn.setBackground(getResources().getDrawable(R.drawable.btn_buy_xml)); } if (!database.enoughCash("shield") || database.getLvl("shield") >= 5) { shieldBtn.setBackground(getResources().getDrawable(R.drawable.btn_buy_no)); } else { shieldBtn.setBackground(getResources().getDrawable(R.drawable.btn_buy_xml)); } // Add listeners to all the buttons gunsBtn.setOnClickListener(buttonListener); shieldBtn.setOnClickListener(buttonListener); engineBtn.setOnClickListener(buttonListener); backBtn.setOnClickListener(buttonListener); resetBtn.setOnClickListener(buttonListener); yesBtn.setOnClickListener(buttonListener); noBtn.setOnClickListener(buttonListener); //// RADIOBUTTONS switch (gunsLvl) { case 1: { gunsRadio.setBackground(getResources().getDrawable(R.drawable.radio_lvl1)); break; } case 2: { gunsRadio.setBackground(getResources().getDrawable(R.drawable.radio_lvl2)); break; } case 3: { gunsRadio.setBackground(getResources().getDrawable(R.drawable.radio_lvl3)); break; } case 4: { gunsRadio.setBackground(getResources().getDrawable(R.drawable.radio_lvl4)); break; } case 5: { gunsRadio.setBackground(getResources().getDrawable(R.drawable.radio_lvl5)); break; } } switch (engineLvl) { case 1: { engineRadio.setBackground(getResources().getDrawable(R.drawable.radio_lvl1)); break; } case 2: { engineRadio.setBackground(getResources().getDrawable(R.drawable.radio_lvl2)); break; } case 3: { engineRadio.setBackground(getResources().getDrawable(R.drawable.radio_lvl3)); break; } case 4: { engineRadio.setBackground(getResources().getDrawable(R.drawable.radio_lvl4)); break; } case 5: { engineRadio.setBackground(getResources().getDrawable(R.drawable.radio_lvl5)); break; } } switch (shieldLvl) { case 1: { shieldRadio.setBackground(getResources().getDrawable(R.drawable.radio_lvl1)); break; } case 2: { shieldRadio.setBackground(getResources().getDrawable(R.drawable.radio_lvl2)); break; } case 3: { shieldRadio.setBackground(getResources().getDrawable(R.drawable.radio_lvl3)); break; } case 4: { shieldRadio.setBackground(getResources().getDrawable(R.drawable.radio_lvl4)); break; } case 5: { shieldRadio.setBackground(getResources().getDrawable(R.drawable.radio_lvl5)); break; } } }
private void initView() { context = this; sp = getSharedPreferences(SPkeys.SPNAME.getString(), 0); imageLoader = new ImageLoader(context.getApplicationContext()); passengerList = new ArrayList<Passenger>(); allPassengerList = new ArrayList<Passenger>(); xibie_listview = (ListView) findViewById(R.id.xibie_listview); add_passager_rl = (RelativeLayout) findViewById(R.id.add_passager_rl); baoxian_rl = (RelativeLayout) findViewById(R.id.baoxian_rl); lianxiren_icon_imgbtn = (ImageButton) findViewById(R.id.lianxiren_icon_imgbtn); back_imgbtn = (ImageButton) findViewById(R.id.back_imgbtn); home_imgbtn = (ImageButton) findViewById(R.id.home_imgbtn); train_num_tv = (TextView) findViewById(R.id.train_num_tv); train_type_tv = (TextView) findViewById(R.id.train_type_tv); runtime_tv = (TextView) findViewById(R.id.runtime_tv); start_station_tv = (TextView) findViewById(R.id.start_station_tv); start_time_tv = (TextView) findViewById(R.id.start_time_tv); start_date_tv = (TextView) findViewById(R.id.start_date_tv); end_station_tv = (TextView) findViewById(R.id.end_station_tv); end_time_tv = (TextView) findViewById(R.id.end_time_tv); end_date_tv = (TextView) findViewById(R.id.end_date_tv); seat_grad_tv = (TextView) findViewById(R.id.seat_grad_tv); ticket_price_tv = (TextView) findViewById(R.id.ticket_price_tv); remain_count_tv = (TextView) findViewById(R.id.remain_count_tv); modify_seat_tv = (TextView) findViewById(R.id.modify_seat_tv); add_passager_tv = (TextView) findViewById(R.id.add_passager_tv); djsx_tv = (TextView) findViewById(R.id.djsx_tv); baoxian_price_and_count_tv = (TextView) findViewById(R.id.baoxian_price_and_count_tv); order_totalmoney_tv = (TextView) findViewById(R.id.order_totalmoney_tv); contact_person_phone_et = (ClearEditText) findViewById(R.id.contact_person_phone_et); yanzhengma_input_et = (ClearEditText) findViewById(R.id.yanzhengma_input_et); passenger_head_divid_line = findViewById(R.id.passenger_head_divid_line); passenger_listview = (ListView) findViewById(R.id.passenger_listview); start_station_icon_iv = (ImageView) findViewById(R.id.start_station_icon_iv); end_station_icon_iv = (ImageView) findViewById(R.id.end_station_icon_iv); yanzhengma_iv = (ImageView) findViewById(R.id.yanzhengma_iv); order_now_btn = (Button) findViewById(R.id.order_now_btn); back_imgbtn.setOnClickListener(btnClickListner); home_imgbtn.setOnClickListener(btnClickListner); modify_seat_tv.setOnClickListener(btnClickListner); yanzhengma_iv.setOnClickListener(btnClickListner); ((TextView) findViewById(R.id.djsx_tv)).setOnClickListener(btnClickListner); add_passager_rl.setOnClickListener(btnClickListner); order_now_btn.setOnClickListener(btnClickListner); baoxian_price_and_count_tv.setOnClickListener(btnClickListner); baoxian_rl.setOnClickListener(btnClickListner); lianxiren_icon_imgbtn.setOnClickListener(btnClickListner); getIntentTrainInfo(); train_num_tv.setText(ti.getTrainID()); train_type_tv.setText(ti.getTrainType()); runtime_tv.setText("历时:" + ti.getRunTime()); start_station_tv.setText(ti.getStationS()); end_station_tv.setText(ti.getStationE()); seat_grad_tv.setText(ti.getSeat_Type()); ticket_price_tv.setText("¥" + ticket_price); remain_count_tv.setText("余票" + ti.getRemain_Count() + "张"); start_time_tv.setText(ti.getGoTime()); end_time_tv.setText(ti.getETime()); adapter_xibie = new MyListAdapter(context, ti.getSeatList()); adapter_xibie.setCurrentID(selectedSeatIndex); remainTicketCount = Integer.valueOf(ti.getRemain_Count()); // adapter_xibie.notifyDataSetChanged(); xibie_listview.setAdapter(adapter_xibie); ActivityInlandAirlineticketBooking.setListViewHeightBasedOnChildren(xibie_listview); xibie_listview.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { try { if (position != selectedSeatIndex) { adapter_xibie.setCurrentID(position); adapter_xibie.notifyDataSetChanged(); } selectedSeatIndex = position; // adapter_xibie.notifyDataSetChanged(); ticket_price = Float.valueOf(ti.getSeatList().get(position).getPrice()); remainTicketCount = Integer.valueOf(ti.getSeatList().get(position).getShengyu()); caculateMoney(); } catch (Exception e) { e.printStackTrace(); } } }); if (selectedSeatIndex == -1) { order_now_btn.setEnabled(false); order_now_btn.setBackground( getResources().getDrawable(R.drawable.booking_immediately_button_d)); } String SFType = ti.getSFType(); if (SFType.length() == 3) { String SType = SFType.substring(0, 1); String FType = SFType.substring(2, 3); if (SType.equals("始")) { start_station_icon_iv.setBackground(getResources().getDrawable(R.drawable.trains_start)); } else if (SType.equals("过")) { start_station_icon_iv.setBackground(getResources().getDrawable(R.drawable.train_over)); } if (FType.equals("终")) { end_station_icon_iv.setBackground(getResources().getDrawable(R.drawable.train_final)); } else if (FType.equals("过")) { end_station_icon_iv.setBackground(getResources().getDrawable(R.drawable.train_over)); } } getValidCodePic(); // 获取验证码信息 // 对于常用联系人,直接返回上次订票时的联系人手机号,若不存在则返回本机手机号码 if (sp.getString(SPkeys.trainContactPhone.getString(), "").equals("")) contact_person_phone_et.setText(CommonFunc.getPhoneNumber(context)); else contact_person_phone_et.setText(sp.getString(SPkeys.trainContactPhone.getString(), "")); caculateMoney(); }
private void setupViews() { tweet = getIntent().getParcelableExtra("tweet"); ivUserProfile = (ImageView) findViewById(R.id.ivUserProfile); tvBody = (TextView) findViewById(R.id.tvBody); tvTimestamp = (TextView) findViewById(R.id.tvCreatedAt); tvUserName = (TextView) findViewById(R.id.tvScreenName); tvFav = (TextView) findViewById(R.id.tvFav); tvRetweet = (TextView) findViewById(R.id.tvRetweet); if (tweet.getUser().getProfileImageUri() != null) { Picasso.with(this).load(tweet.getUser().getProfileImageUri()).into(ivUserProfile); } tvBody.setText(tweet.getBody()); tvTimestamp.setText(RelativeTime.getRelativeTimeAgo(tweet.getCreatedAt())); tvUserName.setText("@" + tweet.getUser().getScreenName()); ivRetweet = (ImageView) findViewById(R.id.ivRetweet); ivReplyView = (ImageView) findViewById(R.id.ivReply); ivFav = (ImageView) findViewById(R.id.ivFav); ivRetweet.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(getApplicationContext(), RetweetActivity.class); i.putExtra("tweet", tweet); v.getContext().startActivity(i); } }); ivReplyView.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(getApplicationContext(), ComposeActivity.class); i.putExtra("tweet", tweet); v.getContext().startActivity(i); } }); ivFav.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { if (!tweet.getIsFavorite()) { client.postFavorite( new JsonHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, JSONObject response) { ivFav.setImageResource(R.drawable.fav_red); tweet = Tweet.fromJson(response); tvFav.setText(String.valueOf(tweet.getFavoriteCount())); } @Override public void onFailure( int statusCode, Header[] headers, Throwable t, JSONObject response) { Log.d("Error", response.toString()); } }, String.valueOf(tweet.getUid())); } else { client.deleteFavorite( new JsonHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, JSONObject response) { ivFav.setImageResource(R.drawable.favorite); tweet = Tweet.fromJson(response); tvFav.setText(String.valueOf(tweet.getFavoriteCount())); } @Override public void onFailure( int statusCode, Header[] headers, Throwable t, JSONObject response) { Log.d("Error", response.toString()); } }, String.valueOf(tweet.getUid())); } } }); if (tweet.getIsFavorite() != null && tweet.getIsFavorite()) { ivFav.setBackground(new ColorDrawable(Color.RED)); } tvFav.setText(String.valueOf(tweet.getFavoriteCount())); tvRetweet.setText(String.valueOf(tweet.getRetweetCount())); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#4099FF"))); }
@Override @TargetApi(16) protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); /*Log.e("SYSO",encontrarDirectorio().getPath()); String[] nombres = encontrarDirectorio().list(); for(int i=0; i<nombres.length; i++){ Log.e("SYSO",nombres[i]); } File archivo = new File(encontrarDirectorio().list()[0]);*/ // String path = "/storage/emulated/0/Movies/videos360/video_1.mp4"; // path = encontrarDirectorio().getAbsolutePath().toString(); // Uri uri = Uri.parse(path); // System.out.println("path de la uri " + uri.getPath()); File file = new File(encontrarDirectorio(), "video_2.mp4"); FFmpegMediaMetadataRetriever md = new FFmpegMediaMetadataRetriever(); // MediaMetadataRetriever md = new MediaMetadataRetriever(); Log.e("SYSO", "existe: " + file.exists()); Log.e("SYSO", "nombre: " + file.getAbsolutePath()); // md.setDataSource(getApplicationContext(),uri); Bitmap bmp = null; try { md.setDataSource(file.getAbsolutePath()); // Log.e("SYSO", "titulo del manager: // "+md.extractMetadata(FFmpegMediaMetadataRetriever.METADATA_KEY_TITLE)); // String duracion = md // .extractMetadata(FFmpegMediaMetadataRetriever.METADATA_KEY_DURATION); // Log.e("SYSO", "duracion video: " + duracion); // md.getFrameAtTime(2000000, MediaMetadataRetriever.OPTION_CLOSEST); bmp = md.getFrameAtTime(5000000, FFmpegMediaMetadataRetriever.OPTION_CLOSEST_SYNC); // FFmpegFrameGrabber g = new FFmpegFrameGrabber("textures/video/anim.mp4"); // Log.e("SYSO", "nombre bmp: "+bmp.toString()); // g.start(); // byte[] bytes =md.getEmbeddedPicture(); // Log.e("SYSO", "bytes: "+bytes.length); md.release(); /*try{ FrameGrabber fg = FrameGrabber.createDefault(file); fg.start(); // CanvasFrame, FrameGrabber, and FrameRecorder use Frame objects to communicate image data. // We need a FrameConverter to interface with other APIs (Android, Java 2D, or OpenCV). OpenCVFrameConverter.ToIplImage converter = new OpenCVFrameConverter.ToIplImage(); // FAQ about IplImage and Mat objects from OpenCV: // - For custom raw processing of data, createBuffer() returns an NIO direct // buffer wrapped around the memory pointed by imageData, and under Android we can // also use that Buffer with Bitmap.copyPixelsFromBuffer() and copyPixelsToBuffer(). // - To get a BufferedImage from an IplImage, or vice versa, we can chain calls to // Java2DFrameConverter and OpenCVFrameConverter, one after the other. // - Java2DFrameConverter also has static copy() methods that we can use to transfer // data more directly between BufferedImage and IplImage or Mat via Frame objects. IplImage grabbedImage = converter.convert(fg.grab()); int width = grabbedImage.width(); int height = grabbedImage.height(); IplImage grayImage = IplImage.create(width, height, IPL_DEPTH_8U, 1); IplImage rotatedImage = grabbedImage.clone(); }catch(org.bytedeco.javacv.FrameGrabber.Exception ex){ Log.e("SYSO","error al crear el framegrabber"); }*/ /*MediaExtractor me = new MediaExtractor(); try{ me.setDataSource(file.getAbsolutePath()); Log.e("SYSO","sampletime: "+me.getSampleTime()); }catch(IOException ex){ Log.e("SYSO","ha habido una excepcion IO"); }*/ } catch (IllegalArgumentException ex) { Log.e("METADATA", "illegal argument"); } if (bmp == null) { TextView texto = new TextView(getApplicationContext()); texto.setText(file.getName()); RelativeLayout padre = (RelativeLayout) findViewById(R.id.padre); padre.addView(texto); } else { ImageView view = (ImageView) findViewById(R.id.imageView); BitmapDrawable drawable = new BitmapDrawable(getResources(), bmp); view.setBackground(drawable); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_friend_in_game); toolbar = (Toolbar) findViewById(R.id.tool_bar); setSupportActionBar(toolbar); // start media if (mediaPlayer == null) { mediaPlayer = MediaPlayer.create(this, R.raw.carefree); mediaPlayer.isLooping(); mediaPlayer.start(); } levelNumberString = getIntent().getExtras().getString("LevelNumber"); setTitle(levelNumberString); String numberString = levelNumberString.substring(levelNumberString.length() - 1); levelNumberInt = Integer.parseInt(numberString); /** setup the map */ boardHoles(); int blocksize = blockSize(levelWidth); LinearLayout llHorizontal = (LinearLayout) findViewById(R.id.linearlayout_main); llHorizontal.setBackgroundColor(R.color.bgBlue); for (int c = 1; c < levelWidth + 1; c++) { LinearLayout llVertical = new LinearLayout(this); llVertical.setOrientation(LinearLayout.VERTICAL); // add 5 blocks for (int r = 1; r < levelLength + 1; r++) { if (!arrayD.contains(r * 10 + c)) { ImageView ib = new ImageView(this); Bitmap b = decodeSampledBitmapFromResource( getResources(), R.drawable.empty_block, blocksize, blocksize); BitmapDrawable bitmapDrawable = new BitmapDrawable(getResources(), b); ib.setImageDrawable(bitmapDrawable); // set border final int sdk = android.os.Build.VERSION.SDK_INT; if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) { ib.setBackgroundDrawable(getResources().getDrawable(R.drawable.border)); } else { ib.setBackground(getResources().getDrawable(R.drawable.border)); } int id = r * 10 + c; ib.setOnClickListener(onClickListener); ib.setId(id); llVertical.addView(ib); blockNumbers++; } else { ImageView ib = new ImageView(this); Bitmap b = decodeSampledBitmapFromResource( getResources(), R.drawable.block_black, blocksize, blocksize); BitmapDrawable bitmapDrawable = new BitmapDrawable(getResources(), b); ib.setImageDrawable(bitmapDrawable); // set border final int sdk = android.os.Build.VERSION.SDK_INT; if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) { ib.setBackgroundDrawable(getResources().getDrawable(R.drawable.border)); } else { ib.setBackground(getResources().getDrawable(R.drawable.border)); } int id = 1000 + r * 10 + c; ib.setId(id); llVertical.addView(ib); blockNumbers++; } } llHorizontal.addView(llVertical); // turn TextView tv = (TextView) findViewById(R.id.playerAB); if (turn == 0) { tv.setText("Orange"); tv.setTextColor(Color.parseColor("#ff9000")); } } }
/** 设置图标 */ public void setIcon(Drawable drawable) { iv.setBackground(drawable); }
/** * set image of star to image view * * @param starImage - star image view * @param imageBG - background image path */ private void setImageBgToStar(ImageView starImage, String imageBG) { starImage.setBackground(new BitmapDrawable(null, this.getBitmap(imageBG))); }
@SuppressLint("UseSparseArrays") public AlphabetWavesView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); final Resources res = context.getResources(); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AlphabetWavesView, defStyle, 0); mMaxOffset = a.getDimensionPixelSize(R.styleable.AlphabetWavesView_leMaxOffset, 54); mMoveCount = a.getInteger(R.styleable.AlphabetWavesView_leMoveCount, 7); mPopAnimTime = a.getInteger(R.styleable.AlphabetWavesView_lePopAnimTime, 120); mToastBg = a.getDrawable(R.styleable.AlphabetWavesView_leAlphabetToastBg); mSelectedBg = a.getDrawable(R.styleable.AlphabetWavesView_leSelectedBg); mToastOffset = a.getDimensionPixelSize( R.styleable.AlphabetWavesView_leToastOffset, res.getDimensionPixelSize(R.dimen.le_awv_toast_offset)); mToastTextSize = a.getDimensionPixelSize( R.styleable.AlphabetWavesView_leToastTextSize, res.getDimensionPixelSize(R.dimen.le_awv_toast_text_size)); mAlphabetTextSize = a.getDimensionPixelSize( R.styleable.AlphabetWavesView_leAlphabetTextSize, res.getDimensionPixelSize(R.dimen.le_awv_alphabet_text_size)); mAlphabetMaxOffset = a.getDimensionPixelSize( R.styleable.AlphabetWavesView_leAlphabetMaxOffset, res.getDimensionPixelSize(R.dimen.le_awv_alphabet_max_offset)); mPaddingTopBottom = a.getDimensionPixelSize( R.styleable.AlphabetWavesView_lePaddingTopBottom, res.getDimensionPixelSize(R.dimen.le_awv_padding_top_bottom)); mAlphabetLeftMargin = a.getDimensionPixelSize( R.styleable.AlphabetWavesView_leAlphabetLeftMargin, res.getDimensionPixelSize(R.dimen.le_awv_alphabet_left_margin)); a.recycle(); if (mToastBg == null) { mToastBg = res.getDrawable(R.drawable.le_alphabet_toast_bg); } if (mSelectedBg == null) { mSelectedBg = res.getDrawable(R.drawable.le_alphabet_selected_bg); } mViewWidth = res.getDimensionPixelSize(R.dimen.le_awv_width); mHandler = new GestureHandler(); mAlphabetList = new ArrayList<Alphabet>(); mAnimMap = new HashMap<Integer, ValueAnimator>(); mSelectedRect.set(0, 0, mSelectedBg.getIntrinsicWidth(), mSelectedBg.getIntrinsicHeight()); isShowSelected = true; mPreviewImage = new ImageView(context); mPreviewImage.setMinimumWidth(mToastBg.getIntrinsicWidth()); mPreviewImage.setMinimumHeight(mToastBg.getIntrinsicHeight()); mPreviewImage.setBackground(mToastBg); mPreviewImage.setAlpha(0f); final int textMinSize = Math.max(0, mToastBg.getIntrinsicHeight() - 0); mPrimaryText = createPreviewTextView(); mPrimaryText.setMinimumWidth(textMinSize); mPrimaryText.setMinimumHeight(textMinSize); mSecondaryText = createPreviewTextView(); mSecondaryText.setMinimumWidth(textMinSize); mSecondaryText.setMinimumHeight(textMinSize); setGravity(Gravity.CENTER); setPadding(0, mPaddingTopBottom, 0, mPaddingTopBottom); }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup myFragmentView = (ViewGroup) inflater.inflate(R.layout.fragment_patient_information, container, false); CustomTextView lblAllergyRiskNotes = (CustomTextView) myFragmentView.findViewById(R.id.lblAllergyRiskNotes); lblAllergyRiskNotes.setText(Html.fromHtml(getString(R.string.lblAllergyRiskNotes))); Linkify.addLinks(lblAllergyRiskNotes, Linkify.WEB_URLS); imgPatientPhoto = (ImageView) myFragmentView.findViewById(R.id.patient_photo); etPatientsFName = (CustomEditTextView) myFragmentView.findViewById(R.id.etPatientsFName); etPatientsMName = (CustomEditTextView) myFragmentView.findViewById(R.id.etPatientsMName); etPatientsLName = (CustomEditTextView) myFragmentView.findViewById(R.id.etPatientsLName); etIWasBornDate = (CustomEditTextView) myFragmentView.findViewById(R.id.etIWasBornDate); etBornAt = (CustomEditTextView) myFragmentView.findViewById(R.id.etBornAt); etIWasDeliveredBy = (CustomEditTextView) myFragmentView.findViewById(R.id.etIWasDeliveredBy); etWhenIWasBornIWeighed = (CustomEditTextView) myFragmentView.findViewById(R.id.etWhenIWasBornIWeighed); etAndIMeasured = (CustomEditTextView) myFragmentView.findViewById(R.id.etAndIMeasured); etGrowthTrackerHead = (CustomEditTextView) myFragmentView.findViewById(R.id.etGrowthTrackerHead); etGrowthTrackerChest = (CustomEditTextView) myFragmentView.findViewById(R.id.etGrowthTrackerChest); etGrowthTrackerAbdomen = (CustomEditTextView) myFragmentView.findViewById(R.id.etGrowthTrackerAbdomen); etCircumcisedOn = (CustomEditTextView) myFragmentView.findViewById(R.id.etCircumcisedOn); etEarsPiercedOn = (CustomEditTextView) myFragmentView.findViewById(R.id.etEarsPiercedOn); etDistinguishingMarks = (CustomEditTextView) myFragmentView.findViewById(R.id.etDistinguishingMarks); etNewBornScreening = (CustomEditTextView) myFragmentView.findViewById(R.id.etNewBornScreening); etVaccinationsGiven = (CustomEditTextView) myFragmentView.findViewById(R.id.etVaccinationsGiven); etMomFName = (CustomEditTextView) myFragmentView.findViewById(R.id.etMomFName); etMomMName = (CustomEditTextView) myFragmentView.findViewById(R.id.etMomMName); etMomLName = (CustomEditTextView) myFragmentView.findViewById(R.id.etMomLName); etSheWorksAt = (CustomEditTextView) myFragmentView.findViewById(R.id.etSheWorksAt); etSheWorksAtAs = (CustomEditTextView) myFragmentView.findViewById(R.id.etSheWorksAtAs); etHerHMOIs = (CustomEditTextView) myFragmentView.findViewById(R.id.etHerHMOIs); etDadFName = (CustomEditTextView) myFragmentView.findViewById(R.id.etDadFName); etDadMName = (CustomEditTextView) myFragmentView.findViewById(R.id.etDadMName); etDadLName = (CustomEditTextView) myFragmentView.findViewById(R.id.etDadLName); etHeWorksAt = (CustomEditTextView) myFragmentView.findViewById(R.id.etHeWorksAt); etHeWorksAtAs = (CustomEditTextView) myFragmentView.findViewById(R.id.etHeWorksAtAs); etHisHMOIs = (CustomEditTextView) myFragmentView.findViewById(R.id.etHisHMOIs); etILiveAtAddress1 = (CustomEditTextView) myFragmentView.findViewById(R.id.etILiveAtAddress1); etILiveAtAddress2 = (CustomEditTextView) myFragmentView.findViewById(R.id.etILiveAtAddress2); spinnerMyMomGaveBirthToMeThrough = (Spinner) myFragmentView.findViewById(R.id.spinnerMyMomGaveBirthToMeThrough); CustomAdapter adapterMyMomGaveBirthToMeThrough = new CustomAdapter( getActivity(), android.R.layout.simple_spinner_item, ICareApplication.populateTypeOfDelivery()); spinnerMyMomGaveBirthToMeThrough.setAdapter(adapterMyMomGaveBirthToMeThrough); spinnerAllergyRisk = (Spinner) myFragmentView.findViewById(R.id.spinnerAllergyRisk); CustomAdapter adapterAllergyRisk = new CustomAdapter( getActivity(), android.R.layout.simple_spinner_item, ICareApplication.populateAllergyRisk()); spinnerAllergyRisk.setAdapter(adapterAllergyRisk); // Log.d("mParamPatientData.getPatientphoto().length", // ""+mParamPatientData.getPatientphoto().length); if (mParamMyPicture != null) { Bitmap bMap = BitmapFactory.decodeByteArray(mParamMyPicture, 0, mParamMyPicture.length); imgPatientPhoto.setBackground(Utils.resizedBitmapDisplay(getActivity(), bMap)); } etPatientsFName.setText(mParamPatientData.getFirtname()); etPatientsMName.setText(mParamPatientData.getMiddlename()); etPatientsLName.setText(mParamPatientData.getLastname()); etIWasBornDate.setText(mParamPatientData.getbDate()); etBornAt.setText(mParamPatientData.getbPlace()); etIWasDeliveredBy.setText(mParamPatientData.getDrName()); // Set Selection Delivery Type int spinnerPosition = adapterMyMomGaveBirthToMeThrough.getPosition(mParamPatientData.getDeliveryType()); spinnerMyMomGaveBirthToMeThrough.setSelection(spinnerPosition); etWhenIWasBornIWeighed.setText(mParamPatientData.getpWeight()); etAndIMeasured.setText(mParamPatientData.getpHeight()); etGrowthTrackerHead.setText(mParamPatientData.getpHead()); etGrowthTrackerChest.setText(mParamPatientData.getpChest()); etGrowthTrackerAbdomen.setText(mParamPatientData.getpAbdomen()); // Set Selection Delivery Type int spinnerPositionAllergy = adapterAllergyRisk.getPosition(mParamPatientData.getAllergyRisk()); spinnerAllergyRisk.setSelection(spinnerPositionAllergy); etCircumcisedOn.setText(mParamPatientData.getpCircumcisedOn()); etEarsPiercedOn.setText(mParamPatientData.getpEarPiercedOn()); etDistinguishingMarks.setText(mParamPatientData.getpDistinguishingMarks()); etNewBornScreening.setText(mParamPatientData.getpNewbornScreening()); etVaccinationsGiven.setText(mParamPatientData.getpVaccinationsGiven()); etMomFName.setText(mParamPatientData.getpMomsFname()); etMomMName.setText(mParamPatientData.getpMomsMname()); etMomLName.setText(mParamPatientData.getpMomsLname()); etSheWorksAt.setText(mParamPatientData.getpMomsWorkPlace()); etSheWorksAtAs.setText(mParamPatientData.getpMomsWorkAs()); etHerHMOIs.setText(mParamPatientData.getpMomsHMO()); etDadFName.setText(mParamPatientData.getpDadsFname()); etDadMName.setText(mParamPatientData.getpDadsMname()); etDadLName.setText(mParamPatientData.getpDadsLname()); etHeWorksAt.setText(mParamPatientData.getpDadsWorkPlace()); etHeWorksAtAs.setText(mParamPatientData.getpDadsWorkAs()); etHisHMOIs.setText(mParamPatientData.getpDadsHMO()); etILiveAtAddress1.setText(mParamPatientData.getpAddress1()); etILiveAtAddress2.setText(mParamPatientData.getpAddress2()); return myFragmentView; }