本文整理汇总了Java中android.support.v4.print.PrintHelper类的典型用法代码示例。如果您正苦于以下问题:Java PrintHelper类的具体用法?Java PrintHelper怎么用?Java PrintHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PrintHelper类属于android.support.v4.print包,在下文中一共展示了PrintHelper类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: printPhoto
import android.support.v4.print.PrintHelper; //导入依赖的package包/类
public void printPhoto() {
if (!(albumItem instanceof Photo)) {
Toast.makeText(this, R.string.error, Toast.LENGTH_SHORT).show();
return;
}
PrintHelper photoPrinter = new PrintHelper(this);
photoPrinter.setScaleMode(PrintHelper.SCALE_MODE_FIT);
try {
photoPrinter.printBitmap(albumItem.getPath(),
albumItem.getUri(this));
} catch (FileNotFoundException e) {
Toast.makeText(this, "Error (FileNotFoundException)", Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
}
示例2: Click
import android.support.v4.print.PrintHelper; //导入依赖的package包/类
@OnClick({R.id.printHelper, R.id.genPdf})
public void Click(View view) {
switch (view.getId()) {
case R.id.printHelper:
PrintHelper mPrintHelper = new PrintHelper(this);
mPrintHelper.setColorMode(PrintHelper.SCALE_MODE_FIT);
Bitmap mBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.a5);
mPrintHelper.printBitmap("print-bitmap", mBitmap);
break;
case R.id.genPdf:
genPdfFile();
break;
default:
break;
}
}
示例3: printImage
import android.support.v4.print.PrintHelper; //导入依赖的package包/类
public void printImage()
{
if (PrintHelper.systemSupportsPrint())
{
// use Android Support Library's PrintHelper to print image
PrintHelper printHelper = new PrintHelper(getContext());
// fit image in page bounds and print the image
printHelper.setScaleMode(PrintHelper.SCALE_MODE_FIT);
printHelper.printBitmap("Doodlz Image", bitmap);
}
else
{
// display message indicating that system does not allow printing
Toast message = Toast.makeText(getContext(),
R.string.message_error_printing, Toast.LENGTH_SHORT);
message.setGravity(Gravity.CENTER, message.getXOffset() / 2,
message.getYOffset() / 2);
message.show();
}
}
示例4: type
import android.support.v4.print.PrintHelper; //导入依赖的package包/类
public static SubjectFactory<PrintHelperSubject, PrintHelper> type() {
return new SubjectFactory<PrintHelperSubject, PrintHelper>() {
@Override
public PrintHelperSubject getSubject(FailureStrategy fs, PrintHelper that) {
return new PrintHelperSubject(fs, that);
}
};
}
示例5: print
import android.support.v4.print.PrintHelper; //导入依赖的package包/类
private void print() {
// Get the print manager.
PrintHelper printHelper = new PrintHelper(this);
// Set the desired scale mode.
printHelper.setScaleMode(PrintHelper.SCALE_MODE_FIT);
// Get the bitmap for the ImageView's drawable.
Bitmap bitmap = ((BitmapDrawable) mImageView.getDrawable()).getBitmap();
// Print the bitmap.
printHelper.printBitmap("Print Bitmap", bitmap);
}
示例6: printImage
import android.support.v4.print.PrintHelper; //导入依赖的package包/类
private void printImage(String fileName, Bitmap bitmap) {
if (PrintHelper.systemSupportsPrint()) {
PrintHelper printHelper = new PrintHelper(this);
printHelper.setColorMode(PrintHelper.COLOR_MODE_COLOR);
printHelper.setScaleMode(PrintHelper.SCALE_MODE_FIT);
printHelper.printBitmap(fileName, bitmap);
} else {
Toast.makeText(this, "この端末では印刷をサポートしていません", Toast.LENGTH_SHORT)
.show();
}
}
示例7: PrintHelperSubject
import android.support.v4.print.PrintHelper; //导入依赖的package包/类
protected PrintHelperSubject(FailureStrategy failureStrategy, PrintHelper subject) {
super(failureStrategy, subject);
}
示例8: doPhotoPrint
import android.support.v4.print.PrintHelper; //导入依赖的package包/类
private void doPhotoPrint(Bitmap bitmap) {
PrintHelper photoPrinter = new PrintHelper(this);
photoPrinter.setScaleMode(PrintHelper.SCALE_MODE_FIT);
photoPrinter.printBitmap("Design print", bitmap);
}
示例9: printWithAdapter
import android.support.v4.print.PrintHelper; //导入依赖的package包/类
private void printWithAdapter(String jobName, PrintDocumentAdapter adapter) {
if (PrintHelper.systemSupportsPrint()) {
PrintManager printManager =
(PrintManager) getSystemService(Context.PRINT_SERVICE);
printManager.print(jobName, adapter, null);
} else {
Toast.makeText(this,
"この端末では印刷をサポートしていません",
Toast.LENGTH_SHORT).show();
}
}
示例10: printHtml
import android.support.v4.print.PrintHelper; //导入依赖的package包/类
private void printHtml(String fileName, WebView webView) {
if (PrintHelper.systemSupportsPrint()) {
PrintDocumentAdapter adapter = webView.createPrintDocumentAdapter();
PrintManager printManager = (PrintManager) getSystemService(Context.PRINT_SERVICE);
printManager.print(fileName, adapter, null);
} else {
Toast.makeText(this, "この端末では印刷をサポートしていません", Toast.LENGTH_SHORT)
.show();
}
}
示例11: PrintHelperAssert
import android.support.v4.print.PrintHelper; //导入依赖的package包/类
public PrintHelperAssert(PrintHelper actual) {
super(actual, PrintHelperAssert.class);
}