我知道这个问题被多次询问,我已经完成了所有的解决方案,但问题仍然存在.
我希望我的文本长度为50个字符.现在它有2行.
以下是我的所作所为:
<TextView
android:id="@+id/notification_Message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/notification_head"
android:layout_centerHorizontal="true"
android:layout_margin="10dp"
android:gravity="center"
android:ellipsize="end"
android:maxLength="50"
android:text=" Hello developer. please check this message for long length. max length to 50 characters. "
android:textSize="20sp" />
Run Code Online (Sandbox Code Playgroud)
这里的文字只是我添加的示例文本.它没有显示3个点,而是显示最多50个字符的消息.我也试过最大线,单线也假.但没有积极的结果.我也不想通过逻辑上添加三个点来以编程方式处理这个事情.
请帮忙
我正在使用默认的弹出菜单,并期望相同的行为.一切都很好.我关注的是弹出菜单的渲染.我的弹出菜单显示在屏幕右侧.
我主要无法为弹出菜单提供正确的保证金.请帮忙.我试过为PopUp菜单提供Gravity.但弹出菜单粘在屏幕右侧.
PopupMenu popupMenu = new PopupMenu(mContext, anchor, Gravity.LEFT);
popupMenu.getMenuInflater().inflate(R.menu.menu_edit_accessory, popupMenu.getMenu());
Run Code Online (Sandbox Code Playgroud) 我想将日期解析成所需的格式,但我每次都收到一个例外.我知道这很容易实现,但我面临一些问题,不知道究竟在哪里:
Exception: java.text.ParseException: Unparseable date: "2014-06-04" (at offset 5)
Run Code Online (Sandbox Code Playgroud)
以下是我的代码:
private String getconvertdate(String date) {
DateFormat inputFormat = new SimpleDateFormat("yyyy-MMM-dd HH:mm:ss",Locale.ENGLISH);
inputFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
DateFormat outputFormat = new SimpleDateFormat("dd-MMM-yyyy",Locale.ENGLISH);
Date parsed = null;
try {
parsed = inputFormat.parse(date);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String outputText = outputFormat.format(parsed);
return outputText;
}
Run Code Online (Sandbox Code Playgroud)
方法输入:2014-06-04
预期产出:2014年6月6日
我跟着一些Ref.来自Stackoverflow.com,但他仍然存在问题.请帮忙.
我在android中通过蓝牙发送图像,想要获取正在发送图像的设备的MAC地址.
请在下面找到我的代码.
private void bluetoothadd(){
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter == null) {
// Device does not support Bluetooth
Log.e("Bluetooth ","not found");
}
if (!mBluetoothAdapter.isEnabled()) {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivity(enableBtIntent);
Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
// If there are paired devices
if (pairedDevices.size() > 0) {
// Loop through paired devices
for (BluetoothDevice device : pairedDevices) {
Log.e("Mac Addressess","are: "+mBluetoothAdapter.getRemoteDevice(device.getAddress()));
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我正在获取所有配对设备的MAC地址.我只想要设备的MAC地址来传输数据.
我想在 AlertDialog 中以粗体显示消息文本的一部分。
我试过:
添加<b> </b> tag在strings.xml,但没有积极的。
我也用过 Html.fromHtml("<b>"+getString(R.string.ittformulanote)+"</b>")
我也去过stackoverflow.com但没有积极的结果。
在我的代码下面:
showDialog(getActivity(),"Sample",Html.fromHtml("<b>"+getString(R.string.ittformulanote)+"</b>")+"\n\n"+));
public static void showDialog(Context mContext, String Title,
String Description) {
final AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
dialog.setTitle(Title);
// dialog.setMessage((Html.fromHtml("<b>"+Description+"</b>")));
dialog.setMessage(Description);
dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
// TODO Auto-generated method stub
}
});
//
AlertDialog alert=dialog.create();
// dialog.show();
alert.show();
}
Run Code Online (Sandbox Code Playgroud) 我已经使用GCM实现了推送通知,当我收到通知时,我希望在我创建了自定义对话框的对话框中显示.
现在,我希望我的对话框出现,即使设备被锁定,无论是模式匹配还是PIN.
我做了以下尝试,但没有积极的结果.
public void onAttachedToWindow() {
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
| WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
| WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
}
Run Code Online (Sandbox Code Playgroud)
并且
public void onAttachedToWindow() {
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
+ WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
+ WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
+ WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
}
Run Code Online (Sandbox Code Playgroud)
清单中的权限:
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
Run Code Online (Sandbox Code Playgroud)
并且还添加了
android:showOnLockScreen="true"
Run Code Online (Sandbox Code Playgroud)
对于屏幕锁定时我想要显示的活动.
请帮忙.
我正在使用发送意图(ACTION_SEND)共享图像.
我想知道是否选择了任何应用程序进行共享.我怎么能这样做,如何知道图像是否成功发送?
我用来共享图像的代码在这里:
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/*");
share.putExtra(Intent.EXTRA_STREAM,Uri.fromFile(new File(imageSharePath)));
startActivity(Intent.createChooser(share, "Share Image"));
Run Code Online (Sandbox Code Playgroud) 我有一个自定义listView,我通过自定义适配器设置内容.我无法了解如何进行不同的操作.我有一个活动延伸活动课只有来回这我打电话"onPostExecute()"我的自定义适配器.如何使电话,短信和电子邮件功能工作.
以下是我的代码
protected void
onPostExecute(String result) {
super.onPostExecute(result);
ListAdapter adapter = new AdapterListView(
AndroidJSONParsingActivity.this, contactList,
R.layout.list_item, new String[] { TAG_COMPANY_NAME, TAG_EMAIL,TAG_PERSON_DESIGNATION ,TAG_NUMBER},
new int[] { R.id.name, R.id.email,R.id.designation,R.id.phone });
// if (ImageURL != null && ImageURL != "")
// imageloader.displayImage(Utils.getEncodedUrl(ImageURL),
// logo_icon_image, options);
list.setAdapter(adapter);
dialog.dismiss();
};
}
Run Code Online (Sandbox Code Playgroud) 我正在使用Netbeans IDE设计一个小型桌面应用程序,并且正在使用JXDatePicker来获取日期。是否可以使用户将可编辑字段设为不可编辑,即仅单击按钮即可允许用户在字段中添加日期。
我尝试过发送但短信会自动发送而不知道.我想发送短信与To字段从我的代码预定义,并可以获得内置的短信APP.
我的守则
holder.SMS.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Log.e("sssssss", "aaaaaaaa");
try {
// View view = (View) v.getParent();
// TextView number = (TextView) view.findViewById(R.id.phone);
// String selected_mobile_sms = number.getText().toString();
// Log.e("sssssss", "ssssssss" + selected_mobile_sms);
// sendSMS();
SmsManager sm = SmsManager.getDefault();
sm.sendTextMessage("tel:121", null, "test message", null,
null);
//
//
// Intent sendIntent = new Intent(Intent.ACTION_VIEW);
// sendIntent.putExtra("sms_body", "");
// //
// sendIntent.setType("vnd.android-dir/mms-sms");
// activity.startActivity(sendIntent);
} catch (Exception e) {
e.printStackTrace();
}
// TODO Auto-generated method stub …Run Code Online (Sandbox Code Playgroud) android ×9
java ×2
android-date ×1
bluetooth ×1
dialog ×1
popupmenu ×1
smsmanager ×1
swing ×1
textview ×1