Questions tagged «android»

Android是Google的移动操作系统,用于对数字设备(智能手机,平板电脑,汽车,电视,Wear,Glass和IoT)进行编程或开发。对于与Android相关的主题,请使用特定于Android的标签,例如android-intent,android-activity,android-adapter等。对于与开发或编程无关但与Android框架相关的问题,请使用以下链接:https:// android.stackexchange.com。

5
字符串资源文件中的format语句
我在通常的strings.xml资源文件中定义了这样的字符串: <string name="hello_world"> HELLO</string> 是否可以定义以下格式的字符串 result_str = String.format("Amount: %.2f for %d days ", var1, var2); 在strings.xml资源文件中? 我尝试转义特殊字符,但无法正常工作。

13
在EditText Kotlin中设置文本
我正在尝试在EditText中设置文本,但是它说: Type mismatch. Required: Editable Found: String 我的代码如下: String name = "Paramjeet" val nametxt = findViewById (R.id.nametxt) as EditText nametxt.text = name 不要说使用,setText因为我使用的是Kotlin,而不是Java。


18
从Android的操作栏中删除图标/徽标
我一直在尝试找到从操作栏中删除图标/徽标的方法,但是经过一个小时的搜索之后,我唯一发现的内容是,如何从Android的文档和Google中整体删除标题栏。那不是我想要的。只想从标题栏中删除图标/徽标。 有人知道如何做到这一点吗?最好是我想用XML做到这一点。




3
ListView的回收机制如何工作
因此,我遇到了以前遇到的问题,很自然地我在这里寻求帮助。Luksprog的答案很好,因为我不知道ListView和GridView如何通过回收Views进行优化。因此,根据他的建议,我能够更改将视图添加到GridView的方式。现在的问题是我有一些没有意义的东西。这是getView我的BaseAdapter: public View getView(int position, View convertView, ViewGroup parent) { if(convertView == null) { LayoutInflater inflater = LayoutInflater.from(parent.getContext()); convertView = inflater.inflate(R.layout.day_view_item, parent, false); } Log.d("DayViewActivity", "Position is: "+position); ((TextView)convertView.findViewById(R.id.day_hour_side)).setText(array[position]); LinearLayout layout = (LinearLayout)convertView.findViewById(R.id.day_event_layout); //layout.addView(new EventFrame(parent.getContext())); TextView create = new TextView(DayViewActivity.this); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0, (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 62, getResources().getDisplayMetrics()), 1.0f); params.topMargin …

6
选择文件对话框[关闭]
关闭。此问题不符合堆栈溢出准则。它当前不接受答案。 想改善这个问题吗?更新问题,使其成为Stack Overflow 的主题。 6年前关闭。 改善这个问题 有人知道完整的选择文件对话框吗?也许您可以在其中过滤掉所有文件(带有特定扩展名的文件除外)? 我还没有找到任何轻量的东西可以轻松地实现到我的项目中。唯一的其他选择似乎是使用OI FileManager的打开意图,但这要求用户已经安装了文件管理器。 如果有人可以指出一个对话框,允许用户浏览文件夹并选择文件,然后返回路径,我将不胜感激。


26
使用TextInputLayout时更改EditText提示颜色
我正在使用TextInputLayout设计库中的新功能。我能够显示它并更改浮动标签的颜色。不幸的是,实际EditText提示现在总是白色。 我尝试过以XML,样式和编程方式更改hintColor,也尝试使用,android.support.v7.widget.AppCompatEditText 但EditText提示始终显示为白色。 下面是我的XML我TextInputLayout和EditText <android.support.design.widget.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content" android.support.design:hintTextAppearance="@style/GreenTextInputLayout"> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/city" android:textColorHint="@color/black" android:hint="@string/city" /> </android.support.design.widget.TextInputLayout> 这是我正在使用的样式TextInputLayout(我尝试将hintTextColor属性设置为黑色,但没有为我做任何事情): <style name="GreenTextInputLayout" parent="@style/TextAppearance.AppCompat"> <item name="android:textColor">@color/homestory_green</item> </style>


8
Android:使用Intent共享纯文本(向所有消息传递应用程序)
我正在尝试使用意图共享一些文本: Intent i = new Intent(android.content.Intent.ACTION_SEND); i.setType("text/plain"); i.putExtra(android.content.Intent.EXTRA_TEXT, "TEXT"); 并与选择器一起变形: startActivity(Intent.createChooser(sms, getResources().getString(R.string.share_using))); 有用!但仅适用于电子邮件应用程序。 我需要的是所有消息传递应用程序的一般意图:电子邮件,短信,即时消息(Whatsapp,Viber,Gmail,SMS ...)尝试使用android.content.Intent.ACTION_VIEW 并且不使用i.setType("vnd.android-dir/mms-sms");任何帮助... ("vnd.android-dir/mms-sms"仅使用短信共享!)

6
当我的应用程序进入后台时,如何防止Android截屏?
我当前正在构建的应用程序要求该应用程序必须防止操作系统出于安全原因将其推入后台时截取该应用程序的屏幕截图。这样,当在应用程序之间切换时,它将无法看到上一个活动屏幕。 我打算将此功能放在应用程序类的onPause方法中,但首先我需要了解如何实现此功能。 那么,有没有人知道如何解决此问题?


By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.