@Override public boolean onOptionsItemSelected(MenuItem item) { String title = (String) item.getTitle(); if (title.equals("添加")) { final HashMap<String, String> add_journal = new HashMap<String, String>(); LayoutInflater inflater = LayoutInflater.from(this); LinearLayout linearLayout = (LinearLayout) inflater.inflate(R.layout.journal_clickitem, null); AlertDialog.Builder builder = new AlertDialog.Builder(Record_Journal.this); final EditText titleEditText = (EditText) linearLayout.findViewById(R.id.journal_title_editText); final EditText contentEditText = (EditText) linearLayout.findViewById(R.id.journal_content_editText); titleEditText.setEnabled(true); contentEditText.setEnabled(true); builder.setPositiveButton( "保 存", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { // To change body of implemented methods use File | Settings | File Templates. add_journal.put("title", String.valueOf(titleEditText.getText())); add_journal.put("body", String.valueOf(contentEditText.getText())); String date = String.valueOf(new SimpleDateFormat("yyyy-MM-dd").format(new Date())); add_journal.put("time", date); add_journal.put("userID", Login.userID); if (myJournalNetwork.add(add_journal)) { Toast.makeText(Record_Journal.this, "添加成功", Toast.LENGTH_SHORT); } else { Toast.makeText(Record_Journal.this, "添加失败", Toast.LENGTH_SHORT); } record_journal_adapter.notifyDataSetChanged(); } }); builder.setNegativeButton( "取 消", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { // To change body of implemented methods use File | Settings | File Templates. } }); builder.setTitle("添加日志").setView(linearLayout); builder.show(); } else if (title.equals("帮助")) { Menu_Functions.helpMe(this); } else if (title.equals("联系")) { Menu_Functions.contactMe(this); } return super.onOptionsItemSelected( item); // To change body of overridden methods use File | Settings | File Templates. }
public View getView(int position, View convertView, ViewGroup parent) { final View view = (convertView != null) ? convertView : LayoutInflater.from(parent.getContext()) .inflate(R.layout.bookmark_item, parent, false); final ImageView imageView = (ImageView) view.findViewById(R.id.bookmark_item_icon); final TextView textView = (TextView) view.findViewById(R.id.bookmark_item_text); final TextView bookTitleView = (TextView) view.findViewById(R.id.bookmark_item_booktitle); final Bookmark bookmark = getItem(position); if (bookmark == null) { imageView.setVisibility(View.VISIBLE); imageView.setImageResource(R.drawable.ic_list_plus); textView.setText(ZLResource.resource("bookmarksView").getResource("new").getValue()); bookTitleView.setVisibility(View.GONE); } else { imageView.setVisibility(View.GONE); textView.setText(bookmark.getText()); if (myCurrentBook) { bookTitleView.setVisibility(View.GONE); } else { bookTitleView.setVisibility(View.VISIBLE); bookTitleView.setText(bookmark.getBookTitle()); } } return view; }
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { holder = new ViewHolder(); convertView = LayoutInflater.from(getActivity()).inflate(R.layout.item_song, null); holder.mTvName = (TextView) convertView.findViewById(R.id.tv_name); holder.mTvArtist = (TextView) convertView.findViewById(R.id.tv_artist); holder.mTvDuration = (TextView) convertView.findViewById(R.id.tv_duration); holder.aboveView = convertView.findViewById(R.id.item_root); holder.behindView = convertView.findViewById(R.id.behind); convertView.setTag(holder); convertViewList.add((PullRightLayout) convertView); } else { holder = (ViewHolder) convertView.getTag(); } if (HideApplication.showListAnim) { startAnim(convertView); } SongInfo info = SongManager.with(getActivity()).getSongByIndex(position); holder.mTvName.setText(info.getTitle()); holder.mTvArtist.setText(info.getArtist() + " - " + info.getAlbum()); holder.mTvDuration.setText( CommonUtils.durationToString(info.getDuration()) + " - " + CommonUtils.getFileSize(info.getPath())); setItemSelected(holder, info.getId() == playingId); convertView.setOnClickListener(new OnItemClick(position)); holder.behindView.setOnClickListener(new OnBehindClick(position)); return convertView; }
@Override public HomeListAdapter.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) { View view = LayoutInflater.from(viewGroup.getContext()) .inflate(R.layout.listview_homemenu, viewGroup, false); ViewHolder vh = new ViewHolder(view); return vh; }
private void initPagerItems() { for (int i = 0; i < bitmapList.size(); i++) { View v = LayoutInflater.from(this).inflate(R.layout.call_activity_itempage, null); ImageView imageView = (ImageView) v.findViewById(R.id.contactIv); TextView textView = (TextView) v.findViewById(R.id.contactTv); imageView.setImageBitmap(bitmapList.get(i)); textView.setText(nameList.get(i)); viewArrayList.add(v); } }
public void setAccounts(int layoutResourceId, List<Account> accounts) { this.layoutResourceId = layoutResourceId; this.accounts = accounts; layoutInflater = LayoutInflater.from(getContext()); for (int i = 0; i < accounts.size(); i++) { View view = getView(i, null, this); view.setVisibility(GONE); this.addView(view); } this.getChildAt(currentPosition).setVisibility(VISIBLE); this.gestureListener = new GestureListener(); this.gesturedetector = new GestureDetector(getContext(), gestureListener); }
private void init() { setVerticalFadingEdgeEnabled(false); headerContainer = (LinearLayout) LayoutInflater.from(getContext()).inflate(R.layout.ptr_header, null); header = (RelativeLayout) headerContainer.findViewById(R.id.ptr_id_header); text = (TextView) header.findViewById(R.id.ptr_id_text); lastUpdatedTextView = (TextView) header.findViewById(R.id.ptr_id_last_updated); image = (ImageView) header.findViewById(R.id.ptr_id_image); spinner = (ProgressBar) header.findViewById(R.id.ptr_id_spinner); pullToRefreshText = getContext().getString(R.string.ptr_pull_to_refresh); releaseToRefreshText = getContext().getString(R.string.ptr_release_to_refresh); refreshingText = getContext().getString(R.string.ptr_refreshing); lastUpdatedText = getContext().getString(R.string.ptr_last_updated); flipAnimation = new RotateAnimation( 0, -180, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f); flipAnimation.setInterpolator(new LinearInterpolator()); flipAnimation.setDuration(ROTATE_ARROW_ANIMATION_DURATION); flipAnimation.setFillAfter(true); reverseFlipAnimation = new RotateAnimation( -180, 0, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f); reverseFlipAnimation.setInterpolator(new LinearInterpolator()); reverseFlipAnimation.setDuration(ROTATE_ARROW_ANIMATION_DURATION); reverseFlipAnimation.setFillAfter(true); addHeaderView(headerContainer); setState(State.PULL_TO_REFRESH); scrollbarEnabled = isVerticalScrollBarEnabled(); ViewTreeObserver vto = header.getViewTreeObserver(); vto.addOnGlobalLayoutListener(new PTROnGlobalLayoutListener()); super.setOnItemClickListener(new PTROnItemClickListener()); super.setOnItemLongClickListener(new PTROnItemLongClickListener()); }
@Override public void onCreate(Bundle bundle) { super.onCreate(bundle); Thread.setDefaultUncaughtExceptionHandler( new org.geometerplus.zlibrary.ui.android.library.UncaughtExceptionHandler(this)); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); requestWindowFeature(Window.FEATURE_NO_TITLE); setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL); final SearchManager manager = (SearchManager) getSystemService(SEARCH_SERVICE); manager.setOnCancelListener(null); final TabHost host = getTabHost(); LayoutInflater.from(this).inflate(R.layout.bookmarks, host.getTabContentView(), true); myBook = SerializerUtil.deserializeBook(getIntent().getStringExtra(FBReader.BOOK_KEY)); }
public View getView(int position, View convertView, ViewGroup parent) { RelativeLayout rowLayout; ServiceAcctInfo acct = acctList[position]; if (convertView == null) { rowLayout = (RelativeLayout) LayoutInflater.from(context).inflate(R.layout.realm_login_row, parent, false); } else { rowLayout = (RelativeLayout) convertView; } String acctType = msgsetNames[acct.type.ordinal()]; if (acct.name.acctType != null) acctType = acctType + " (" + acct.name.acctType + ')'; if (acct.name.acctId != null) acctType = acctType + "\nAccount: " + acct.name.acctId; ((TextView) rowLayout.findViewById(R.id.Name)).setText(acct.desc); ((TextView) rowLayout.findViewById(R.id.TaskList)).setText(acctType); return rowLayout; }
@Override public void onCreate(Bundle bundle) { super.onCreate(bundle); Thread.setDefaultUncaughtExceptionHandler( new org.geometerplus.zlibrary.ui.android.library.UncaughtExceptionHandler(this)); // requestWindowFeature(Window.FEATURE_NO_TITLE); setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL); final TabHost host = getTabHost(); LayoutInflater.from(this).inflate(R.layout.bookmarks, host.getTabContentView(), true); AllBooksBookmarks = Bookmark.bookmarks(); Collections.sort(AllBooksBookmarks, new Bookmark.ByTimeComparator()); final FBReader fbreader = (FBReader) FBReader.Instance(); if (fbreader.Model != null) { final long bookId = fbreader.Model.Book.getId(); for (Bookmark bookmark : AllBooksBookmarks) { if (bookmark.getBookId() == bookId) { myThisBookBookmarks.add(bookmark); } } myThisBookView = createTab("thisBook", R.id.this_book); new BookmarksAdapter(myThisBookView, myThisBookBookmarks, true); } else { findViewById(R.id.this_book).setVisibility(View.GONE); } myAllBooksView = createTab("allBooks", R.id.all_books); new BookmarksAdapter(myAllBooksView, AllBooksBookmarks, false); findViewById(R.id.search_results).setVisibility(View.GONE); }
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); this.deviceInfo = getDeviceInfoFromApplicationContext(); StopWatch sw = new StopWatch(); sw.start("create activity"); createAnimation(); buildFadeInPageViewAnimation(); buildFadeOutPageViewAnimation(); setProgressBarIndeterminateVisibility(false); System.out.println("debug on create"); executor = new ThreadPoolExecutor( 0, Integer.MAX_VALUE, 10L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>()); sourceDB = new SourceDB(this); alarmSender = new AlarmSender(this); // sm = (SensorManager) getSystemService(Context.SENSOR_SERVICE); // acceleromererSensor = sm.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); // createShakeListener(); Cursor sourceCursor = sourceDB.findAll(); startManagingCursor(sourceCursor); sourceAdapter = new SourceItemArrayAdapter<SourceItem>(this, R.layout.source_item, sourceDB, deviceInfo); TelephonyManager tManager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE); deviceId = tManager.getDeviceId(); inflater = LayoutInflater.from(this); accountType = (String) getIntent().getExtras().get("type"); sourceId = (String) getIntent().getExtras().get("sourceId"); sourceImageURL = (String) getIntent().getExtras().get("sourceImage"); sourceName = (String) getIntent().getExtras().get("sourceName"); contentUrl = (String) getIntent().getExtras().get("contentUrl"); //// System.out.println("sourceImageURL:" + sourceImageURL); setContentView(R.layout.main); container = (ViewGroup) findViewById(R.id.pageContainer); pageIndexView = (PageIndexView) findViewById(R.id.pageIndex); ViewSwitcher headerSwitcher = (ViewSwitcher) findViewById(R.id.flipper); header = (HeaderView) findViewById(R.id.header); contentImageButton = (ImageButton) findViewById(R.id.content); contentImageButton.setOnClickListener( new View.OnClickListener() { public void onClick(View view) { overridePendingTransition(android.R.anim.slide_in_left, R.anim.fade); PageActivity.this.finish(); } }); // pageInfo = (TextView)header.findViewById(R.id.pageInfo); headerText = (TextView) findViewById(R.id.headerText); headerImageView = (WebImageView) findViewById(R.id.headerImage); pageViewFactory = new WeiboPageViewFactory(); preferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); this.browseMode = getBrowseMode(); // this.animationMode = getAnimationMode(); refreshingSemaphore = new Semaphore(1, true); Log.v("accountType", accountType); reload(); }
protected Dialog onCreateDialog(int id) { AlertDialog.Builder builder = new AlertDialog.Builder(this); switch (id) { case PROMPT_OAUTH: builder .setMessage(R.string.commentneedsinaoauth) .setCancelable(false) .setPositiveButton( R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { FlipdroidApplications application = (FlipdroidApplications) getApplication(); OAuth oauth = new OAuth(); application.setOauth(oauth); //// System.out.println("OAuthHolder.oauth" + application + oauth); oauth.RequestAccessToken(PageActivity.this, "flipdroid://SinaAccountSaver"); } }) .setNegativeButton( R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) {} }); this.dialog = builder.create(); break; case NAVIGATION: LayoutInflater li = LayoutInflater.from(this); View v = li.inflate(R.layout.dialog_nav_title_view, null); // builder.setView(v); builder.setCustomTitle(v); builder.setAdapter( sourceAdapter, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialogInterface, int i) { Intent intent = new Intent(PageActivity.this, PageActivity.class); SourceItem cursor = sourceAdapter.getItem(i); intent.putExtra("type", cursor.getSourceType()); intent.putExtra("sourceId", cursor.getSourceId()); intent.putExtra("sourceImage", cursor.getSourceImage()); intent.putExtra("sourceName", cursor.getSourceName()); intent.putExtra("contentUrl", cursor.getSourceURL()); if (dialog != null) dialog.dismiss(); startActivity(intent); finishActivity(); } }); this.dialog = builder.create(); Button btn_addshortcut = (Button) v.findViewById(R.id.btnaddshortcut); btn_addshortcut.setText("add shortcut"); btn_addshortcut.setOnClickListener( new Button.OnClickListener() { public void onClick(View v) { addShortcut(); dialog.cancel(); } }); dialog.setOnKeyListener( new DialogInterface.OnKeyListener() { public boolean onKey(DialogInterface dialogInterface, int i, KeyEvent keyEvent) { if (keyEvent.getKeyCode() == KeyEvent.KEYCODE_MENU) { if (dialog != null) { dialog.dismiss(); return true; } } return false; } }); break; default: this.dialog = null; } if (dialog != null) { dialog.setOnDismissListener( new DialogInterface.OnDismissListener() { public void onDismiss(DialogInterface dialogInterface) { dialog = null; } }); } return this.dialog; }
private MonthAdapter() { inflater = LayoutInflater.from(getContext()); }
public PendingBillsAdapter(Context context, List<BillPay> objects) { super(context, 0, objects); inflater = LayoutInflater.from(context); }