public void generateScreen() { List<String> names = presenter.getAccountNames(username, password); LinearLayout layout = (LinearLayout) findViewById(R.id.accountArray); TextView account = new TextView(this); Point size = new Point(); Display display = ((android.view.WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); display.getSize(size); Button temp; if (!(names.size() > 0)) { return; } account.setBackgroundColor(Color.BLACK); account.setHeight(2); account.setWidth(size.x); layout.addView(account); for (String name : names) { temp = new Button(this); temp.setText(name); temp.setGravity(Gravity.CENTER); temp.setOnClickListener(AccountClickListener); layout.addView(temp); account = new TextView(this); account.setWidth(size.x); account.setBackgroundColor(Color.BLACK); account.setHeight(2); layout.addView(account); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LinearLayout layoutMain = new LinearLayout(this); layoutMain.setOrientation(LinearLayout.VERTICAL); layoutMain.setBackgroundColor(Color.CYAN); LinearLayout layoutTitle = new LinearLayout(this); layoutTitle.setOrientation(LinearLayout.VERTICAL); layoutTitle.setGravity(Gravity.TOP); layoutMain.addView(layoutTitle); TextView heading = new TextView(this); heading.setText("DETECTING INPUT EVENTS \n (Click Or Long Press)"); heading.setHeight(100); heading.setGravity(Gravity.TOP | Gravity.CENTER); heading.setBackgroundColor(Color.YELLOW); heading.setTextSize(TypedValue.COMPLEX_UNIT_SP, 25); heading.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD); layoutTitle.addView(heading); LinearLayout layoutBody = new LinearLayout(this); layoutBody.setOrientation(LinearLayout.VERTICAL); layoutBody.setGravity(Gravity.CENTER_HORIZONTAL); layoutMain.addView(layoutBody); Button btn1 = new Button(this); btn1.setWidth(10); btn1.setGravity(Gravity.CENTER); btn1.setTextSize(TypedValue.COMPLEX_UNIT_SP, 25); btn1.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD); btn1.setText("Click Me With Any Style"); layoutBody.addView(btn1); btn1.setOnClickListener(this); btn1.setOnLongClickListener( new View.OnLongClickListener() { public boolean onLongClick(View v) { result.setText("You long pressed the button !!"); return true; } }); result = new TextView(this); result.setHeight(200); result.setGravity(Gravity.CENTER); result.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20); result.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD); layoutBody.addView(result); setContentView(layoutMain); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mSlideListView = ((SlideListView) findViewById(R.id.list_view)); mTestData = new ArrayList<String>(); randomCreateTestData(); mAdapter = new SlideAdapter(this, mTestData); TextView headView1 = new TextView(this); headView1.setHeight(60); TextView headView2 = new TextView(this); headView2.setHeight(60); TextView footerView1 = new TextView(this); footerView1.setHeight(60); headView1.setText("这是HeaderView1"); headView2.setText("这是HeaderView2"); footerView1.setText("这是FooterView1"); mSlideListView.addHeaderView(headView1); mSlideListView.addHeaderView(headView2); mSlideListView.addFooterView(footerView1); mSlideListView.setAdapter(mAdapter); mSlideListView.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String s = (String) parent.getAdapter().getItem(position); if (!TextUtils.isEmpty(s)) { Toast.makeText(MainActivity.this, "OnItemClick:" + s, Toast.LENGTH_SHORT).show(); } } }); mSlideListView.setOnScrollListener( new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { if (scrollState == SCROLL_STATE_IDLE) { Log.d("roamer", "no"); } else { Log.d("roamer", "scroll"); } } @Override public void onScroll( AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {} }); }
@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()); }
/** * 生成MyViewGroup的子元素 * * @param text */ private void createView1(String text, String number) { if (etMess.getText().toString().equals(" ") || etMess.getText().toString().equals("")) { } else { TextView t = new TextView(this); t.setText(text); t.setTextColor(Color.BLACK); t.setGravity(Gravity.CENTER); t.setBackgroundResource(R.drawable.bg_sms_contact_btn); t.setHeight(60); t.setPadding(2, 0, 2, 0); t.setOnClickListener(new MyListener()); t.setTag(number); mvg.addView(t, mvg.getChildCount() - 1); ContactBean cb = new ContactBean(); cb.setDisplayName(text); cb.setPhoneNum(number); if (null == selectContactList) { selectContactList = new ArrayList<ContactBean>(); } selectContactList.add(cb); queryListView.setVisibility(View.INVISIBLE); } }
public View getView(int pos, View v, ViewGroup p) { TextView view = new TextView(PageList.this); view.setText("Item " + pos); Log.i(TAG, "entry: " + pos); view.setTextSize(20f); view.setHeight(80); return view; }
// nova funcio de reestructurar, es posara en marxa a l'hora de dissenyar la // interficie private void reestructurarCaselles(TextView pos) { // ImageView myView = (ImageView)getWindow().findViewById(R.id.ll); Display display = getWindowManager().getDefaultDisplay(); CO.cMaxHor = display.getWidth() - display.getHeight() / 5; CO.cMaxVert = display.getHeight() - display.getHeight() / 5; if (CO.cols == 1) { pos.setWidth(CO.cMaxHor); // cMaxHor es la distancia horitzontal // maxima que tenim. width = CO.cMaxHor; } else if (CO.cols == 2) { pos.setWidth(CO.cMaxHor / 2 - CO.cMaxHor / 20); width = CO.cMaxHor / 2 - CO.cMaxHor / 20; } else if (CO.cols == 3) { pos.setWidth(CO.cMaxHor / 3 - CO.cMaxHor / 20); width = CO.cMaxHor / 3 - CO.cMaxHor / 20; } else { // cols == 4 pos.setWidth(CO.cMaxHor / 4 - CO.cMaxHor / 20); width = CO.cMaxHor / 4 - CO.cMaxHor / 20; } // Aqui a les columnes fa ago raro amb setMaxLines i amb la OR del // principi // i m'agradaria que ho miressim i tal, xq no ho acabo d'entendre. if (CO.rows == 1 || CO.rows == 2) { pos.setHeight(CO.cMaxVert / 2 - CO.cMaxVert / 10); pos.setMaxLines(4); height = CO.cMaxVert / 2 - CO.cMaxVert / 10; } else if (CO.rows == 3) { pos.setHeight(CO.cMaxVert / 3 - CO.cMaxVert / 10); pos.setMaxLines(3); height = CO.cMaxVert / 3 - CO.cMaxVert / 10; } else if (CO.rows == 4) { pos.setHeight(CO.cMaxVert / 4 - CO.cMaxVert / 10); pos.setMaxLines(2); height = CO.cMaxVert / 4 - CO.cMaxVert / 10; } else { // CO.rows == 5 pos.setHeight(CO.cMaxVert / 5 - CO.cMaxVert / 10); pos.setMaxLines(2); height = CO.cMaxVert / 5 - CO.cMaxVert / 10; } }
@Override public View getGroupView(int arg0, boolean arg1, View arg2, ViewGroup arg3) { TextView tv_help_title = (TextView) LayoutInflater.from(ctx).inflate(R.layout.help_title, null); tv_help_title.setText(parents.get(arg0)); tv_help_title.setHeight((int) ctx.getResources().getDimension(R.dimen.item_h_90)); tv_help_title.setPadding((int) ctx.getResources().getDimension(R.dimen.l_r_35), 0, 0, 0); return tv_help_title; }
private void reiniciarCasella(TextView posicio) { if (posicio != null) { posicio.setBackgroundColor(Color.TRANSPARENT); posicio.setTextColor(Color.TRANSPARENT); posicio.setPadding(0, 0, 0, 0); posicio.setHeight(0); posicio.setWidth(0); posicio.setText(null); } }
/** * 打开单选框 * * @param context 上下文 * @param parameters 参数列表 */ public static void showSelector( Context context, final IEventable<Integer> callback, String... parameters) { final AlertDialog alertDialog = new AlertDialog.Builder(context).create(); alertDialog.show(); Window window = alertDialog.getWindow(); WindowManager.LayoutParams layoutParams = window.getAttributes(); layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT; window.setGravity(Gravity.BOTTOM); window.setAttributes(layoutParams); LinearLayout contentLayout = new LinearLayout(context); LinearLayout.LayoutParams contentLayoutParams = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); contentLayout.setGravity(Gravity.BOTTOM); contentLayout.setOrientation(LinearLayout.VERTICAL); contentLayout.setBackgroundColor(context.getResources().getColor(R.color.grey_bg)); boolean sentry = false; int position = -1; for (int i = 0; i < parameters.length; i++) { String parameter = parameters[i]; if (Text.isBlank(parameter)) { sentry = true; continue; } position++; TextView textView = new TextView(context); textView.setText(parameter); textView.setTag(position); textView.setGravity(Gravity.CENTER); textView.setTextColor(context.getResources().getColor(R.color.grey_text)); textView.setTextSize(18); textView.setBackgroundColor(Color.WHITE); textView.setHeight(GraphicsHelper.dip2px(context, 40)); LinearLayout.LayoutParams textLayoutParams = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); if (sentry) { textLayoutParams.topMargin = GraphicsHelper.dip2px(context, 2); } else { textLayoutParams.topMargin = GraphicsHelper.dip2px(context, 1); } contentLayout.addView(textView, textLayoutParams); textView.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { callback.on((Integer) v.getTag()); alertDialog.cancel(); } }); } window.setContentView(contentLayout, contentLayoutParams); }
private void setContent(final TextView view, final String prefix, final String text) { if (view != null) { if (this.itemHight == 0) { this.itemHight = view.getHeight(); } if ((text != null) && (text.length() > 0)) { view.setText(prefix + text); if (this.itemHight == 0) { this.itemHight = view.getHeight(); } if ((this.itemHight > 0) && (view.getHeight() == 0)) { // Workaround for recycled Items: // Sometimes Text is not visible because previous // ItemHeight==0 is sometimes remembered. view.setHeight(this.itemHight); } } else { view.setHeight(0); } } }
public View getView(int pos, View v, ViewGroup p) { TextView view; if (v == null) { view = new TextView(ListViewForLoading.this); } else { view = (TextView) v; } view.setText("ListItem " + pos); view.setTextSize(20f); view.setGravity(Gravity.CENTER); view.setHeight(60); return view; }
private void createView2(String text) { TextView t = new TextView(this); t.setText(text); t.setTextColor(Color.BLACK); t.setGravity(Gravity.CENTER); t.setHeight(60); t.setPadding(2, 0, 2, 0); t.setBackgroundResource(R.drawable.bg_sms_contact_btn); t.setOnClickListener(new MyListener()); t.setTag(text); mvg.addView(t, mvg.getChildCount() - 1); }
private void addTextViews(LinearLayout linearLayout) { for (int i = 0; i < 26; i++) { TextView text = new TextView(this); text.setText(String.valueOf(i)); text.setTextSize(10); text.setWidth(500); text.setHeight(500); text.setBackgroundColor( Color.rgb( 255 - 10 * i, 255 - 10 * i, 255 - 10 * i)); // just for fun , varying back grounds text.setGravity(Gravity.CENTER); linearLayout.addView(text); } }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); LinearLayout ll = new LinearLayout(getActivity()); ll.setOrientation(LinearLayout.VERTICAL); ll.setGravity(Gravity.BOTTOM); TextView label = new TextView(getActivity()); label.setText(R.string.gcode_fragment_by); label.setTextSize(20); label.setGravity(Gravity.CENTER); label.setHeight(100); ll.addView(label); mLayout.addView(ll); return mLayout; }
@Override public View getView(int position, View view, ViewGroup arg2) { LinearLayout ln = new LinearLayout(context); ln.setGravity(Gravity.CENTER); TextView item_tv = new TextView(context); item_tv.setText(list.get(position) + ""); int w = (screenWidth - 70) * 3 / 5 / 7; item_tv.setWidth(w); item_tv.setHeight(w); item_tv.setTextSize(15); item_tv.setGravity(Gravity.CENTER); item_tv.setId(949494); item_tv.setBackgroundColor(Color.parseColor("#eeeeee")); int num = Integer.parseInt(item_tv.getText().toString()); // 当天背景颜色为浅蓝色 if (isNowDate()) { if (position == todayPosition) { item_tv.setBackgroundDrawable( context.getResources().getDrawable(R.drawable.date_share_check_df)); item_tv.setTextColor(Color.WHITE); } } // 选中是背景 if (position < 7 && num > 7) { item_tv.setTextColor(Color.parseColor("#BEBBBB")); } else if (position > 14 && num < 7) { item_tv.setTextColor(Color.parseColor("#BEBBBB")); } else { item_tv.setTextColor(Color.parseColor("#858585")); // 点击时背景颜色高亮 if (list.get(position) == clickPosition) { item_tv.setBackgroundDrawable( context.getResources().getDrawable(R.drawable.date_share_check)); item_tv.setTextColor(Color.WHITE); } } ln.addView(item_tv); view = ln; return view; }
@SuppressWarnings("deprecation") @Override public View getView(int position, View convertView, ViewGroup parent) { final DialogMenuItem item = contents.get(position); LinearLayout ll_item = new LinearLayout(context); ll_item.setOrientation(LinearLayout.HORIZONTAL); ll_item.setGravity(Gravity.CENTER_VERTICAL); ImageView iv_item = new ImageView(context); iv_item.setPadding(0, 0, dp2px(15), 0); ll_item.addView(iv_item); TextView tv_item = new TextView(context); tv_item.setLayoutParams( new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); tv_item.setSingleLine(true); tv_item.setGravity(Gravity.CENTER); tv_item.setTextColor(itemTextColor); tv_item.setTextSize(TypedValue.COMPLEX_UNIT_SP, itemTextSize_SP); tv_item.setHeight(dp2px(itemHeight_DP)); ll_item.addView(tv_item); float radius = dp2px(cornerRadius_DP); if (isTitleShow) { ll_item.setBackgroundDrawable( (CornerUtils.listItemSelector( radius, Color.TRANSPARENT, itemPressColor, position == contents.size() - 1))); } else { ll_item.setBackgroundDrawable( CornerUtils.listItemSelector( radius, Color.TRANSPARENT, itemPressColor, contents.size(), position)); } iv_item.setImageResource(item.resId); tv_item.setText(item.operName); iv_item.setVisibility(item.resId == 0 ? View.GONE : View.VISIBLE); return ll_item; }
private void SetBackGroundforList() { // TODO Auto-generated method stub mDownView_parent_txt1 = new TextView(activity.getApplicationContext()); RelativeLayout.LayoutParams lp1 = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); lp1.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); mDownView_parent_txt1.setId(Integer.parseInt("111111")); mDownView_parent_txt1.setLayoutParams(lp1); mDownView_parent_txt1.setGravity(Gravity.CENTER_HORIZONTAL); mDownView_parent_txt1.setText(HalfText); mDownView_parent_txt1.setWidth(textwidth2); mDownView_parent_txt1.setPadding(0, textheight / 4, 0, 0); mDownView_parent_txt1.setHeight(textheight); mDownView_parent_txt1.setBackgroundColor(Color.parseColor(FullColor)); mDownView_parent_txt1.setTextColor(Color.parseColor(TextColor)); mDownView_parent_txt1.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null); mDownView_parent.addView(mDownView_parent_txt1, 0); // if(SwipeType==Double){ // mDownView_parent_txt2 = new TextView(activity.getApplicationContext()); // mDownView_parent_txt2.setId(222222); // RelativeLayout.LayoutParams lp2 =new // RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT); // lp2.addRule(RelativeLayout.LEFT_OF,mDownView_parent_txt1.getId()); // mDownView_parent_txt2.setLayoutParams(lp2); // mDownView_parent_txt2.setGravity(Gravity.CENTER_HORIZONTAL); // mDownView_parent_txt2.setText(FullText); // mDownView_parent_txt2.setWidth(textwidth); // mDownView_parent_txt2.setPadding(0, textheight/4, 0, 0); // mDownView_parent_txt2.setHeight(textheight); // mDownView_parent_txt2.setBackgroundColor(Color.parseColor(FullColor)); // mDownView_parent_txt2.setTextColor(Color.parseColor(TextColor)); // mDownView_parent_txt2.setCompoundDrawablesWithIntrinsicBounds(null , // FullDrawable, null, null ); // mDownView_parent.addView(mDownView_parent_txt2, 1); // } }
@Override protected void onCreate(Bundle savedInstanceState) { try { super.onCreate(savedInstanceState); setTheme(com.actionbarsherlock.R.style.Theme_Sherlock_Light_DarkActionBar); ActionBarSherlock actionBar = getSherlock(); actionBar.setTitle("OpenCms"); getSupportActionBar().setIcon(R.drawable.logo2); getSupportActionBar().setTitle(null); JSONObject json = Config.getMainConfig(); JSONObject mobApp = json.getJSONObject("MobileApplication"); JSONArray tabulars = mobApp.getJSONArray("Tabs"); setContentView(R.layout.activity_main); mTabHost = (TabHost) findViewById(android.R.id.tabhost); mTabHost.setup(); mViewPager = (ViewPager) findViewById(R.id.pager); mTabsAdapter = new TabsAdapter(this, mTabHost, mViewPager); mTabHost.getTabWidget().setDividerDrawable(R.drawable.tab_divider); mTabHost.getTabWidget().setStripEnabled(true); for (int i = 0; i < tabulars.length(); i++) { JSONObject tab = tabulars.getJSONObject(i).getJSONObject("Tab"); String title = tab.getString("Title"); Bundle bundle = new Bundle(); bundle.putString("menuId", title); Class<? extends Fragment> fragmentClass = null; if (tab.has("NewsCollector")) { bundle.putString("subtitle", getString(tab, "Subtitle")); fragmentClass = NewsFragment.class; } if (tab.has("EventCollector")) { bundle.putString("subtitle", getString(tab, "Subtitle")); fragmentClass = EventFragment.class; } else if (tab.has("Url")) { fragmentClass = WebContentFragment.class; bundle.putString("url", getString(tab, "Url")); } else if (tab.has("ContactCompanyName")) { fragmentClass = ContactsFragment.class; bundle.putString(ContactsFragment.CONTACT_NAME, getString(tab, "ContactCompanyName")); bundle.putString(ContactsFragment.CONTACT_STREET, getString(tab, "ContactCompanyStreet")); bundle.putString(ContactsFragment.CONTACT_CITY, getString(tab, "ContactCompanyCity")); bundle.putString(ContactsFragment.CONTACT_ZIP, getString(tab, "ContactCompanyZip")); bundle.putString(ContactsFragment.CONTACT_PHONE, getString(tab, "ContactCompanyPhone")); bundle.putString(ContactsFragment.CONTACT_FAX, getString(tab, "ContactCompanyFax")); bundle.putString(ContactsFragment.CONTACT_EMAIL, getString(tab, "ContactCompanyEmail")); bundle.putString(ContactsFragment.CONTACT_WWW, getString(tab, "ContactCompanyWww")); bundle.putString(ContactsFragment.CONTACT_MAP_TYPE, getString(tab, "ContactMapType")); bundle.putString(ContactsFragment.CONTACT_MAP_ZOOM, getString(tab, "ContactMapZoom")); } if (fragmentClass == null) { continue; } // Location info TextView txtTabInfo = new TextView(this); txtTabInfo.setText(title); // txtTabInfo.setBackgroundResource(R.drawable.bg_tab_left_active_right_inactive); txtTabInfo.setTextColor(Color.WHITE); txtTabInfo.setGravity(Gravity.CENTER_HORIZONTAL); txtTabInfo.setHeight(100); View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.tab_layout, null); TextView tv = (TextView) view.findViewById(R.id.textView); tv.setText(title); mTabsAdapter.addTab( mTabHost.newTabSpec(title).setIndicator(view), fragmentClass, bundle, title); } } catch (Exception ex) { ex.printStackTrace(); } }
@Override public boolean setUiBeforShow() { if (style == STYLE_DEFAULT) { widthScale(0.95f); } /** title */ float radius = dp2px(cornerRadius_DP); tv_title.setHeight(dp2px(titleHeight)); tv_title.setBackgroundDrawable( CornerUtils.cornerDrawable( titleBgColor, new float[] {radius, radius, radius, radius, 0, 0, 0, 0})); tv_title.setText(title); tv_title.setTextSize(TypedValue.COMPLEX_UNIT_SP, titleTextSize_SP); tv_title.setTextColor(titleTextColor); tv_title.setVisibility(isTitleShow ? View.VISIBLE : View.GONE); /** title underline */ v_line_title.setLayoutParams( new LayoutParams(LayoutParams.MATCH_PARENT, dp2px(dividerHeight_DP))); v_line_title.setBackgroundColor(dividerColor); v_line_title.setVisibility(isTitleShow ? View.VISIBLE : View.GONE); /** cancel btn */ tv_cancel.setHeight(dp2px(itemHeight_DP)); tv_cancel.setText("取消"); tv_cancel.setTextSize(TypedValue.COMPLEX_UNIT_SP, itemTextSize_SP); tv_cancel.setTextColor(itemTextColor); tv_cancel.setBackgroundDrawable( CornerUtils.listItemSelector(radius, lvBgColor, itemPressColor, 1, 0)); tv_cancel.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { dismiss(); } }); /** listview */ lv.setDivider(new ColorDrawable(dividerColor)); lv.setDividerHeight(dp2px(dividerHeight_DP)); if (isTitleShow) { lv.setBackgroundDrawable( CornerUtils.cornerDrawable( lvBgColor, new float[] {0, 0, 0, 0, radius, radius, radius, radius})); } else { lv.setBackgroundDrawable(CornerUtils.cornerDrawable(lvBgColor, radius)); } if (adapter == null) { adapter = new ListDialogAdapter(); } lv.setAdapter(adapter); lv.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (onOperItemClickL != null) { onOperItemClickL.onOperItemClick(parent, view, position, id); } } }); if (isLacShow) lv.setLayoutAnimation(lac); return false; }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.edit_profile); validity = (TextView) findViewById(R.id.editProfileValidity); validity.setHeight(0); if (Resources.getIdUser() == null) EditProfileActivity.this.startActivity( new Intent(EditProfileActivity.this, CarShareAndroidAplicationActivity.class)); Button saveBtn = (Button) findViewById(R.id.editProfileSaveBtn); Button cencelBtn = (Button) findViewById(R.id.editProfileCencelBtn); phone = (EditText) findViewById(R.id.editProfilePhone); password = (EditText) findViewById(R.id.editProfilePassword); passwordConfirm = (EditText) findViewById(R.id.editProfilePasswordConfirm); email = (EditText) findViewById(R.id.editProfileEmail); firstName = (EditText) findViewById(R.id.editProfileFirstName); lastName = (EditText) findViewById(R.id.editProfileLastName); address = (EditText) findViewById(R.id.editProfileAddress); car = (EditText) findViewById(R.id.editProfileCarDescription); try { DefaultHttpClient httpPostclient = new DefaultHttpClient(); HttpConnectionParams.setConnectionTimeout(httpPostclient.getParams(), 10000); HttpPost httpPostRequest = new HttpPost(Resources.getServer() + "/service/account/info"); httpPostRequest.setHeader("Accept", "application/xml"); httpPostRequest.setHeader("Content-type", "application/xml"); httpPostRequest.addHeader("AuthToken", Resources.getIdUser()); HttpResponse responsePost = (HttpResponse) httpPostclient.execute(httpPostRequest); if (responsePost.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { HttpEntity entity = responsePost.getEntity(); if (entity != null) { InputStream is = entity.getContent(); XmlDeserializer deserializer = new XmlDeserializer(); AutoDeserializerItem userItem = new AutoDeserializerItem("user", null, UserUpdate.class); AutoDeserializer.factory(deserializer, is, userItem).deserialize(); User user = (User) userItem.getItem(); phone.setText(user.getPhoneNumber()); email.setText(user.getEmail()); firstName.setText(user.getFirstName()); lastName.setText(user.getLastName()); address.setText(user.getAddress()); car.setText(user.getCarDescription()); } } } catch (Exception e) { System.exit(1); } saveBtn.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { try { UserUpdate userUpdate = new UserUpdate(); userUpdate.setPhoneNumber(phone.getText().toString()); userUpdate.setEmail(email.getText().toString()); userUpdate.setFirstName(firstName.getText().toString()); userUpdate.setLastName(lastName.getText().toString()); userUpdate.setAddress(address.getText().toString()); userUpdate.setCarDescription(car.getText().toString()); if (password.getText().toString().equals(passwordConfirm.getText().toString())) { if (!password.getText().toString().equals("")) userUpdate.setPassword(password.getText().toString()); XmlSerializer serializer = new XmlSerializer("carshare"); AutoSerializer.factory("user-update", userUpdate, serializer).serialize(); String output = serializer.getResult(); DefaultHttpClient httpPostclient = new DefaultHttpClient(); HttpConnectionParams.setConnectionTimeout(httpPostclient.getParams(), 10000); HttpPost httpPostRequest = new HttpPost(Resources.getServer() + "/service/account/update"); httpPostRequest.setHeader("Accept", "application/xml"); httpPostRequest.setHeader("Content-type", "application/xml"); httpPostRequest.addHeader("AuthToken", Resources.getIdUser()); httpPostRequest.setEntity(new StringEntity(output, HTTP.UTF_8)); HttpResponse responsePost = (HttpResponse) httpPostclient.execute(httpPostRequest); if (responsePost.getStatusLine().getStatusCode() == HttpStatus.SC_OK) msbox("User updated"); } else validity.setHeight(20); } catch (Exception e) { ExitMsbox("Fatal Error!"); } } }); cencelBtn.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { EditProfileActivity.this.startActivity( new Intent(EditProfileActivity.this, MenuActivity.class)); } }); }
public View getView(int position, View convertView, ViewGroup parent) { // Inflate le layout de l'offre si nécessaire if (convertView == null) { LayoutInflater inflater = ((Activity) context).getLayoutInflater(); convertView = inflater.inflate(viewID, parent, false); } Offre offre = getItem(position); if (offre != null) { // Set le font des indicateurs qui apparaissent sur les offres. ((TextView) convertView.findViewById(R.id.item_apply_indicator)).setTypeface(indiatorFont); ((TextView) convertView.findViewById(R.id.item_ignore_indicator)).setTypeface(indiatorFont); // Les valeurs venant de l'offre à mettre dans le layout String titre = offre.getTitre(); String description = offre.getDescription(); String organisme = offre.getOrganismeName(); PersonneContact personne = offre.getPersonneContact(); Lieu lieu = offre.getLieu(); Disponibilite horaire = offre.getDisponibilite(); Duree duree = offre.getDuree(); Calendar dateDebut = offre.getDateDebut(); Calendar dateFin = offre.getDateFin(); int ageMin = offre.getAgeMinimum(); int places = offre.getNombrePlaces(); List<String> competences = offre.getCompetences(); String typeActivite = offre.getType(); // Les views à changer dans le layout offre TextView titreView = (TextView) convertView.findViewById(R.id.lbl_titleValue); TextView descriptionView = (TextView) convertView.findViewById(R.id.lbl_descriptionValue); TextView organismeView = (TextView) convertView.findViewById(R.id.lbl_organismeName); TextView personneNameView = (TextView) convertView.findViewById(R.id.lbl_personneName); TextView personneEmailView = (TextView) convertView.findViewById(R.id.lbl_personneEmail); TableRow lieuView = (TableRow) convertView.findViewById(R.id.row_lieu); TableRow horaireView = (TableRow) convertView.findViewById(R.id.row_horaire); TableRow dureeView = (TableRow) convertView.findViewById(R.id.row_duree); TableRow dateDebutView = (TableRow) convertView.findViewById(R.id.row_dateDebut); TableRow dateFinView = (TableRow) convertView.findViewById(R.id.row_dateFin); TableRow ageMinView = (TableRow) convertView.findViewById(R.id.row_ageMin); TableRow placesView = (TableRow) convertView.findViewById(R.id.row_places); TableRow competencesView = (TableRow) convertView.findViewById(R.id.row_competences); TableRow typeActiviteView = (TableRow) convertView.findViewById(R.id.row_typeActivite); // Changement des valeurs du layout titreView.setText(titre); if (description != null) descriptionView.setText(description); else descriptionView.setHeight(0); organismeView.setText(organisme); if (personne != null) { personneNameView.setText(personne.getFullName()); personneEmailView.setText(personne.getEmail()); } else { personneNameView.setText(offre.getOrganismeName()); personneEmailView.setVisibility(View.GONE); } if (lieu != null) ((TextView) lieuView.getChildAt(1)).setText(lieu.toString()); else lieuView.setVisibility(View.GONE); if (horaire != null) ((TextView) horaireView.getChildAt(1)).setText(horaire.toString()); else horaireView.setVisibility(View.GONE); if (duree != null) ((TextView) dureeView.getChildAt(1)).setText(duree.toString()); else dureeView.setVisibility(View.GONE); if (dateDebut != null) ((TextView) dateDebutView.getChildAt(1)) .setText( dateDebut.get(Calendar.DAY_OF_MONTH) + " " + Mois.get(dateDebut.get(Calendar.MONTH)) + " " + dateDebut.get(Calendar.YEAR)); else dateDebutView.setVisibility(View.GONE); if (dateFin != null) ((TextView) dateFinView.getChildAt(1)) .setText( dateFin.get(Calendar.DAY_OF_MONTH) + " " + Mois.get(dateFin.get(Calendar.MONTH)) + " " + dateFin.get(Calendar.YEAR)); else dateFinView.setVisibility(View.GONE); if (ageMin > 0) ((TextView) ageMinView.getChildAt(1)).setText(ageMin + " an" + ((ageMin > 1) ? "s" : "")); else ageMinView.setVisibility(View.GONE); if (places > 0) ((TextView) placesView.getChildAt(1)) .setText(places + " place" + ((places > 1) ? "s" : "")); else placesView.setVisibility(View.GONE); if (competences.size() > 0) { String competencesString = competences.get(0); for (int i = 1; i < competences.size(); i++) competencesString += ", " + competences.get(i); ((TextView) competencesView.getChildAt(1)).setText(competencesString); } else competencesView.setVisibility(View.GONE); if (typeActivite != null) ((TextView) typeActiviteView.getChildAt(1)).setText(typeActivite); else typeActiviteView.setVisibility(View.GONE); } // Retourne le view pour l'offre courante return convertView; }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Remove title bar this.requestWindowFeature(Window.FEATURE_NO_TITLE); // Remove notification bar this.getWindow() .setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); // set content view AFTER ABOVE sequence (to avoid crash) setContentView(R.layout.player); decorView = getWindow().getDecorView(); uiOption = getWindow().getDecorView().getSystemUiVisibility(); surfaceView = (SurfaceView) this.findViewById(R.id.SurfaceView); surfaceHolder = surfaceView.getHolder(); surfaceHolder.addCallback(this); mediaPlayer = new MediaPlayer(); mediaPlayer.setOnCompletionListener(this); mediaPlayer.setOnErrorListener(this); mediaPlayer.setOnInfoListener(this); mediaPlayer.setOnPreparedListener(this); mediaPlayer.setOnSeekCompleteListener(this); mediaPlayer.setOnVideoSizeChangedListener(this); mMenuBar = (RelativeLayout) findViewById(R.id.menuBar); mMenuButton = (ImageView) findViewById(R.id.menuButton); mVideoList = (LinearLayout) findViewById(R.id.videoList); mTitle = (TextView) findViewById(R.id.MovieTitle); mMenuButton.setOnClickListener(this); mVideoList.setOnClickListener(this); /* * String filePath = Environment.getExternalStorageDirectory().getPath() * + "/Movies/Spanglish_H264_AAC_800x432.mp4"; */ // POINT: sdcard 의 동영상 파일 목록을 구하기 String sdPath = Environment.getExternalStorageDirectory().getAbsolutePath(); File sdRoot = new File(sdPath); FileList(sdRoot); for (int i = 0; i < mFileList.size(); i++) { if ((mFileList.get(i).endsWith(".mp4")) || (mFileList.get(i).endsWith(".mkv"))) { Log.e("TAT", mFileList.get(i)); mVideoFileList.add(mFileList.get(i)); } } if (mVideoFileList.isEmpty()) { Toast.makeText(this, "재생할 파일이 없습니다.", 1).show(); } for (int i = 0; i < mVideoFileList.size(); i++) { final String path = mVideoFileList.get(i); final String filename = path.substring(path.lastIndexOf("/") + 1); final TextView text = new TextView(this); text.setContentDescription(i + ""); text.setSingleLine(); text.setPadding( text.getPaddingLeft() + 10, text.getPaddingTop() + 10, text.getPaddingRight(), text.getPaddingBottom()); text.setHeight(80); text.setText(filename); text.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { try { if (mediaPlayer.isPlaying()) mediaPlayer.stop(); mediaPlayer.reset(); mediaPlayer.setDataSource(path); mediaPlayer.prepare(); idx = Integer.parseInt(text.getContentDescription().toString()); mTitle.setText("[ " + filename + " ]"); } catch (IllegalArgumentException e) { Log.v(LOGTAG, e.getMessage()); finish(); } catch (IllegalStateException e) { Log.v(LOGTAG, e.getMessage()); finish(); } catch (SecurityException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }); mVideoList.addView(text); } /* TODO : intend를 통해 클릭한 동영상 path 넘겨주기 */ // Intent intent = getIntent(); // mmList = intent.getStringArrayListExtra("vList"); String filePath = mVideoFileList.get(0); try { mediaPlayer.setDataSource(filePath); String filename = filePath.substring(filePath.lastIndexOf("/") + 1); mTitle.setText("[ " + filename + " ]"); } catch (IllegalArgumentException e) { Log.v(LOGTAG, e.getMessage()); finish(); } catch (IllegalStateException e) { Log.v(LOGTAG, e.getMessage()); finish(); } catch (IOException e) { Log.v(LOGTAG, e.getMessage()); finish(); } controller = new MediaController(this) { @Override public void show() { super.show(0); mMenuBar.setVisibility(View.VISIBLE); } @Override public void hide() { super.hide(); mMenuBar.setVisibility(View.INVISIBLE); ((ScrollView) mVideoList.getParent()).setVisibility(View.INVISIBLE); } }; currentDisplay = getWindowManager().getDefaultDisplay(); // // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) // uiOption |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; }