我想在我的android应用程序中使用AutoCompleteTextView.我知道如何使用简单的字符串数组,但我希望AutoCompleteTextView使用对象列表来执行完成.我的代码如下:
活动代码
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.search);
initialize();
ArrayAdapter<Student> adapter = new ArrayAdapter<Student>(this,
R.layout.dropdown_list_item, GetAllStudentsList());
searchBox.setAdapter(adapter);
searchBox.setThreshold(THRESHOLD_VALUE);
searchBox.setTextColor(Color.BLACK);
}
searchBox.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view,
int position, long arg3) {
//Here i will grab the Student object that user selected from drop-down
}
});
public ArrayList<Movies> GetAllStudentsList() {
//This method returns a ArrayList of <Student> type objects
}
Run Code Online (Sandbox Code Playgroud)
学生班对象有关于学生的信息ID,NAME,ADDRESS,MARKS.
我知道AutoCompleteTextView需要一个String类型对象的数组来执行搜索操作.在我的情况下,我希望AutoCompleteTextView使用我的ArrayList在Student对象字段NAME的基础上执行完成.我不知道如何指定AutoCompleteTextView使用NAME字段学生对象.请帮我提供任何链接或一个小例子.
谢谢
我在Lyout中有一个文本视图,我想在这个textview中设置一些文本.这应该在一个不是MainActivity类的类中进行.
问题是我得到了一个空指针异常.
这是我的代码:
public class UserInformations extends Activity{
TextView emailTextView;
LocalDatabase localdatabase= new LocalDatabase(this);
public void getUserInformation()
{
emailTextView = (TextView) findViewById(R.id.EmailTextView);
String email = localdatabase.getUserEmail();
emailTextView.setText(email);
}
}
Run Code Online (Sandbox Code Playgroud)
当我在Main Activity类中执行此操作时,它可以正常工作,但它不适用于其他类.
这是我的布局ViewPager.我想更改文本下方当前标签荧光笔的颜色.实际上它以黑色显示.但我不知道它是否是默认的颜色.而且我还有一个疑问.如果我使用PagerTitleStrip此选项卡,则不会出现荧光笔.有没有办法用titletrip带来它?
这是我的布局:
<android.support.v4.view.PagerTabStrip android:id="@+id/pager_title_strip"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:background="@color/pager_titlestrip_bg"
android:textColor="@color/pager_titlestrip_text"
android:paddingTop="5dp"
android:paddingBottom="4dp" >
</android.support.v4.view.PagerTabStrip>
Run Code Online (Sandbox Code Playgroud) 我想在我想要的应用程序中实现此行为[ https://github.com/gleue/TGLStackedViewController].
我想要达到的最接近/效果是Google Chrome浏览器的行为方式.

从这个Android布局拍摄的照片:如何实现类似于卡片组的UI?所以问题
是否有人试图实施这种行为?你们知道任何可以帮助实现这种效果的库吗?这将是非常有帮助的!谢谢
出于环境原因,我只能使用adb命令.
有没有一种方法来获得当前的布局属性,如id,position,text等?
与uiautomatorviewer显示的相似.
我试图使我的按钮不完全在中心,但让我们说在屏幕高度的2/5s,我正在寻找属性失败,所以我试过这种方法
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
android:padding="20dp" >
<ImageButton
android:id="@+id/flashlight_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_above="@+id/fakeView"
android:background="@null"
android:contentDescription="@string/flashlight_button_description"
android:src="@drawable/freeml_bright" />
<View
android:id="@+id/fakeView"
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_centerInParent="true"
android:background="#FFAABB" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
但是它不起作用,即使我在假视图上设置了保证金.
有任何想法吗?
//编辑//
谢谢你的回答家伙,填充属性工作,但因为它是一个大图像,如果我希望它从屏幕高度的2/5开始,它覆盖屏幕的中心点,所以如果我使用填充属性它的工作,但它将它推离中心,不允许它覆盖它.对不起这是我的错
虽然,我使用线性布局工作,我想避免,因为在顶部和底部有更多的视图彼此相邻,所以它将导致使用线性布局的嵌套视图.不幸的是,我认为这是唯一的选择.
它基本上使用另一个线性布局,填充顶部和底部视图未使用的剩余空间,高度= 0dp,权重= 1,并将其重力设置为中心
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="20dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/application_logo_description"
android:src="@drawable/mylight" />
<ImageButton
android:id="@+id/settings_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:background="@null"
android:contentDescription="@string/settings_button_description"
android:src="@drawable/settings_button" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
<ImageButton
android:id="@+id/flashlight_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:contentDescription="@string/flashlight_button_description" …Run Code Online (Sandbox Code Playgroud) android center android-layout android-view android-relativelayout
我有一个LinearLayout,有很多嵌套的LinearLayouts和TextViewss
我的主要活动是膨胀主要的LinearLayout,
然后我从服务器加载数据,并根据收到的数据,我在占位符(LinearLayout)中添加多个布局
这是一个简单的新闻页面,我加载与新闻相关联的图像并将其放在最初为空的LinearLayout中.
每个图像都有以下信息:标题(TextView),日期(TextView),图像(ImageView)所以我实际做的是以下内容:
*请注意,这只是在我提出的所有尝试的问题中必不可少的代码 - > catch ... if/else ....等
public void addImages(JSONArray images){
ViewGroup vg = (ViewGroup) findViewById(R.id.imagesPlaceHolder);
// loop on images
for(int i =0;i<images.length;i++){
View v = getLayoutInflater().inflate(R.layout.image_preview,vg);
// then
I think that here is the problem
ImageView imv = (ImageView) v.findViewById(R.id.imagePreview);
TextView dt = (TextView) v.findViewById(R.id.dateHolder);
TextView ttl = (TextView) v.findViewById(R.id.title);
// then
dt.setText("blablabla");
ttl.setText("another blablabla");
// I think the problem is here too, since it's referring to a single image
imv.setTag( images.getJSONObject(i).getString("image_path").toString() ); …Run Code Online (Sandbox Code Playgroud) 我使用xml创建了一个带有笔触和白色背景的圆圈.如何在用户操作(例如按下连续按钮)时从下到上逐渐填充?
有没有可以用来实现类似事情的免费图书馆?
我正在使用非常天真的代码来显示底部对话框片段:
class LogoutBottomSheetFragment : BottomSheetDialogFragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.view_image_source_chooser, container, false)
return view
}
}
Run Code Online (Sandbox Code Playgroud)
这就是我调用此对话框的方式:
LogoutBottomSheetFragment().show(supportFragmentManager, "logout")
Run Code Online (Sandbox Code Playgroud)
但是我在下面的图片中看到了这个可怕的东西.如何将导航栏保持为白色(背面/主页软件按钮所在的底栏)?

我正在使用的应用主题:
<!-- Base application theme. -->
<style name="BaseAppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
</style
<style name="AppTheme" parent="BaseAppTheme">
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<!-- Main theme colors -->
<!-- your app branding color for the app bar -->
<item name="android:colorPrimary">@color/colorPrimary</item>
<!-- darker variant for the status bar and contextual app …Run Code Online (Sandbox Code Playgroud) android navigationbar android-layout android-view bottom-sheet
在android中,我们可以将片段滑过另一个吗?例如,在下图中:

有两个片段.一个是红色,另一个是蓝色.如果用户将手指按在黑色箭头上并将其向右拖动,则红色片段也随之拖动,从而覆盖蓝色片段.最后,红色片段覆盖整个蓝色片段.此外,如果用户在红色片段被拖动到不到一半的蓝色片段之前抬起他的手指,则红色片段应该回到其原始位置(因此不覆盖蓝色片段).然而,如果用户不抬起他的手指(即拖动箭头)直到红色片段覆盖蓝色片段的一半以上或整个蓝色片段,则红色片段应覆盖整个蓝色片段.
此外,如果红色片段(如Buttons,EditTexts等等)有任何视图,那么它们也会相应地重新调整大小.
有没有办法做到这一点?如果是,那怎么样?
android android-animation android-layout android-fragments android-view