本文整理匯總了Java中android.content.Context.getText方法的典型用法代碼示例。如果您正苦於以下問題:Java Context.getText方法的具體用法?Java Context.getText怎麽用?Java Context.getText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.content.Context
的用法示例。
在下文中一共展示了Context.getText方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: HeaderItem
import android.content.Context; //導入方法依賴的package包/類
HeaderItem(Context context, Session session, boolean connecting) {
if (connecting) {
// Conectando
iconResource = R.drawable.ic_profile;
mainText = context.getText(R.string.connecting);
secondaryText = null;
}
else if (session != null) {
// En Sesión
iconResource = R.drawable.ic_action_name;
mainText = session.getMe().getName();
secondaryText = session.getMe().getProfile().getEmail();
} else {
// Sin Sesión
iconResource = R.drawable.ic_profile;
mainText = context.getText(R.string.default_drawer_message);
secondaryText = context.getText(R.string.default_drawer_mail);
}
}
示例2: detailMusic
import android.content.Context; //導入方法依賴的package包/類
/**
* Song Details
*
* @param context
* @param title
* @param album
* @param artist
* @param trackno
* @param data
*/
public static void detailMusic(Context context, String title, String album, String artist,
int trackno, String data) {
if (data != null) {
File file = new File(data);
if (file.exists()) {
float cal = (file.length() / 1024);
String content = context.getText(R.string.song_Name) +
title +
"\n\n" +
context.getText(R.string.album_name) +
album +
"\n\n" +
context.getString(R.string.artist_name) +
artist +
"\n\n" +
context.getText(R.string.trackno) +
trackno +
"\n\n" +
context.getText(R.string.file_path) +
data +
"\n\n" +
context.getText(R.string.file_size) +
String.valueOf(String.format("%.2f", cal / 1024)) +
" MB";
new MaterialDialog.Builder(context)
.title(R.string.action_details)
.content(content)
.positiveText(R.string.okay)
.typeface(getFont(context), getFont(context))
.onPositive((materialDialog, dialogAction) -> materialDialog.dismiss())
.show();
} else {
Toast.makeText(context, "File path not found", Toast.LENGTH_SHORT).show();
}
} else {
Log.d("Helper", "path not found");
}
}
示例3: updateWidget
import android.content.Context; //導入方法依賴的package包/類
private static void updateWidget(Context context, AppWidgetManager manager, int appWidgetId, boolean serviceRunning) {
RemoteViews updateViews = new RemoteViews(context.getPackageName(), R.layout.widget_recording);
// change the subtext depending on whether the service is running or not
CharSequence subtext = context.getText(
serviceRunning ? R.string.widget_recording_in_progress : R.string.widget_start_recording);
updateViews.setTextViewText(R.id.widget_subtext, subtext);
// if service not running, don't show the "recording" icon
updateViews.setViewVisibility(R.id.record_badge_image_view, serviceRunning ? View.VISIBLE : View.INVISIBLE);
PendingIntent pendingIntent = getPendingIntent(context, appWidgetId);
updateViews.setOnClickPendingIntent(R.id.clickable_linear_layout, pendingIntent);
manager.updateAppWidget(appWidgetId, updateViews);
}
示例4: onDisableRequested
import android.content.Context; //導入方法依賴的package包/類
@Override
public CharSequence onDisableRequested(Context context, Intent intent) {
return context.getText(R.string.device_admin_disable_confirmation);
}