我有一个讨厌的问题.我有EditText(8行)里面ScrollView.当我试图滚动文本时,EditText它的行为并不稳定.有时它会滚动,有时它不会聚焦.
这是我的布局文件,让我的问题更清晰:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="8dp" >
<TextView
android:id="@+id/wo_task_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/no_description" />
<TextView
android:id="@+id/wo_task_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/no_description" />
<TextView
android:id="@+id/wo_task_comments_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@string/comments" />
<Button
android:id="@+id/wo_task_select_comment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/select_comment_from_template" />
<EditText
android:id="@+id/wo_task_comments"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="top|left"
android:hint="@string/enter_your_comment_here"
android:lines="8"
android:maxLines="10"
android:minLines="6"
android:scrollbars="vertical"
android:singleLine="false" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我知道我有这个问题,因为在另一个内部有一个可滚动的控件,但我不知道该怎么做.所以,如果可以,请帮助我.
提前致谢.
public void initComments(final View view) {
EditText comment = (EditText) view.findViewById(R.id.wo_task_comments);
comment.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(final View v, final MotionEvent motionEvent) {
if (view.getId() …Run Code Online (Sandbox Code Playgroud) 我的应用程序中有2个进程.从一个进程我将数据保存到SharedPreferences.从第二个过程 - 检索.当我检索数据时,我收到SharedPreferences旧数据(我检查xml文件,看看,当前收到的文件和数据中的数据是不同的).看起来这个数据是缓存的.我更改了保存方法(提交/应用)但没有结果.PS:例如http://pastebin.com/Zx2ffvSg
//saving
{ ...
SharedPreferences myPrefs = this.getSharedPreferences("myPrefs", MODE_PRIVATE);
SharedPreferences.Editor prefsEditor = myPrefs.edit();
prefsEditor.putString(MY_NAME, "Sai");
prefsEditor.putString(MY_WALLPAPER, "f664.PNG");
prefsEditor.commit();
... }
//retrieving
// when i call getData() I put "this" as argument.
public void getData(Context context){
SharedPreferences myPrefs = context.getSharedPreferences("myPrefs", MODE_PRIVATE);
...}
Run Code Online (Sandbox Code Playgroud) 你好我在Android工作室得到渲染错误.有人知道这是为什么造成的吗?
我的xml:
<!-- ListRow Left side Thumbnail image -->
<LinearLayout
android:id="@+id/thumbnail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginRight="5dip"
android:background="@drawable/image_bg"
android:padding="0dip" >
<ImageView
android:id="@+id/list_image"
android:layout_width="50dip"
android:layout_height="50dip"
android:scaleType="centerCrop"
/>
</LinearLayout>
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/thumbnail"
android:layout_marginTop="0dip"
android:layout_toRightOf="@+id/thumbnail"
android:text="De Titel van het geweldige bericht"
android:textColor="#60a926"
android:textSize="15dip"
android:textStyle="bold"
android:ellipsize="end"
android:typeface="sans" />
<TextView
android:id="@+id/subtitle"
android:layout_width="match_parent"
android:layout_height="25dp"
android:layout_below="@id/title"
android:layout_marginTop="0dip"
android:layout_toLeftOf="@+id/imageView1"
android:layout_toRightOf="@+id/thumbnail"
android:text="Nieuwsbericht subtitel mooi iets ..."
android:textStyle="bold"
android:ellipsize="end"
android:textColor="#9f9e9f"
android:textSize="10dip" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="@drawable/arrow" />
<!-- datum van bericht -->
<TextView
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/artist" …Run Code Online (Sandbox Code Playgroud) 我添加了单个用户的数据像这样:
Realm realm = Realm.getDefaultInstance();
newUser = new UserDatabase();
realm.executeTransaction(new Realm.Transaction() {
public void execute(Realm realm) {
newUser.setClassName(classSectionName);
newUser.setClassNO(classNO);
newUser.setImageUrl(imageUrl);
newUser.setRollNo(rollNO);
newUser.setSchool(school);
// and now saved the data in peresistant data like this:
realm.copyToRealm(newUser);
}
});
Run Code Online (Sandbox Code Playgroud)
但我无法找到从Realm数据库中删除单个条目的方法,即使我尝试这样,它也无法正常工作.
Realm realm = Realm.getDefaultInstance();
UserDatabase tempUser = new UserDatabase();
final RealmResults<UserDatabase> students = realm.where(UserDatabase.class).findAll();
for(int i=0 ; i<students.size();i++){
final int index =i;
if((students.get(i).getUserID()).equals(prefs.getString(QRActivity.USER_ID_AFTER_LOGIN,"jpt"))&&
(students.get(i).getUserName()).equals(prefs.getString(QRActivity.USER_NAME_AFTER_LOGIN,"jpt"))){
realm.executeTransaction(new Realm.Transaction() {
public void execute(Realm realm) {
//Trying to delete a row from realm.
students.deleteFromRealm(index);
}
});
} …Run Code Online (Sandbox Code Playgroud) 我正在使用RecyclerView它显示不同的类别列表。每个行项目还包含RecyclerView显示类别项目的列表。父级RecyclerView填充为垂直LinearLayoutManager,子级RecyclerViews填充为GridLayoutManager(2 列)。即使子项RecyclerViews有很多类别项,也不会显示除前 2 个类别项之外的所有类别项。所有剩余的类别项目都针对特定类别隐藏。换句话说,您可以说子项的RecyclerView扩展程度没有其包含的项目那么多。
我在这里找到了不同的解决方案,但没有一个有效。这就是我再次发帖的原因。
我是 android 编程新手,我想DatePicker在我的布局中使用 element 。我能够成功使用它,但我不知道如何更改其选定的日期颜色。我在这个网站上读过很多帖子,他们谈论了改变DatePickerDialog. 我尝试对DatePicker元素遵循类似的方法,但无法做到。我可以更改日期的textColorusingcalendarTextColor属性。我的布局文件代码如下:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<DatePicker
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/datePicker"
android:datePickerMode="calendar"
android:spinnersShown="false"
android:layout_gravity="center"
android:layout_marginTop="-52dp"
android:layout_marginBottom="-20dp"
style="@style/MyDatePickerStyleTheme"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
这是相应的 styles.xml 代码:
<style name="MyDatePickerStyleTheme" parent="@android:style/Theme.Holo.Light.Dialog">
<item name="colorAccent"> #00ff00 </item>
<item name="android:datePickerStyle">@style/MyDatePickerStyle</item>
<item name="android:colorPrimary"> #00ff00 </item>
<item name="android:colorPrimaryDark"> #00ff00 </item>
<item name="android:colorAccent"> #00ff00 </item>
<item name="android:backgroundTint"> #00ff00 </item>
<!-- <item name="android:calendarTextColor"> #00ff00 </item> -->
</style>
<style name="MyDatePickerStyle">
<item name="android:calendarTextColor"> #00ff00 </item>
</style>
Run Code Online (Sandbox Code Playgroud)
我想补充一些额外的观点:
android:calendarTextColor如果我把它放在里面,属性就可以工作MyDatePickerStyleTheme,但是当我把它放在里面时,属性就不起作用MydatePickerStyle …我正在尝试使用Firebase存储下载图像.我写了以下代码
MainActivity.java
public class MainActivity extends AppCompatActivity {
ArrayList<Car> carListSuper;
RecyclerView rvCarList;
ProgressBar progressbar;
private CarListAdapter carListAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
carListSuper = new ArrayList<>();
Firebase myFirebaseRef = new Firebase("https://carbar-7dae7.firebaseio.com/");
rvCarList = (RecyclerView) findViewById(R.id.rvCarList);
rvCarList.setItemAnimator(new FeedItemAnimator());
progressbar = (ProgressBar) findViewById(R.id.progressCarLoad);
carListAdapter = new CarListAdapter(carListSuper,MainActivity.this);
RecyclerView.LayoutManager linearLayoutManager = new LinearLayoutManager(this);
rvCarList.setLayoutManager(linearLayoutManager);
rvCarList.setAdapter(carListAdapter);
myFirebaseRef.child("carList").addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot snapshot) {
Log.i("saz",snapshot.getValue().toString());
progressbar.setVisibility(View.GONE);
carListSuper.clear();
//String jsonString = snapshot.getValue().toString();
try {
for (int i=0; i<snapshot.getChildrenCount();i++) {
//Car carList …Run Code Online (Sandbox Code Playgroud) 我喜欢CollapsingToolbarLayout用RecyclerView,喜欢Whatsapp.
以下是捕获的视频:https://sendvid.com/0oi2lxx5
所以当我向上滚动它没关系,但是当我向下滚动时它不顺畅.我想顺利滚动它RecyclerView.
所以这是我的profile_activity.xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:id="@+id/profile_recyclerview"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_below="@+id/profileactivity_appbar" />
<android.support.design.widget.AppBarLayout
android:id="@+id/profileactivity_appbar"
android:layout_width="match_parent"
android:layout_height="400dp"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme3.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/profileactivity_collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp">
<ImageView
android:id="@+id/profileactivity_fullimage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax"
app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_collapseMode="pin" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin"
app:layout_anchor="@id/profileactivity_appbar"
app:layout_anchorGravity="bottom|right|end"
app:backgroundTint="@color/ColorPrimary"
android:src="@drawable/ic_create_white_48dp"/>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
我在用:
compile 'com.android.support:appcompat-v7:23.4.0'
compile …Run Code Online (Sandbox Code Playgroud) android android-recyclerview android-collapsingtoolbarlayout nestedscrollview
我有一个关于将数据传递BroadcastReceiver给a的严重问题Activity.让我们仔细看看我的问题.我有一个PhoneStateReceiver extends BroadcastReceiver曾经收到传入电话的课程.
public class PhoneStateReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
try {
System.out.println("Receiver start");
String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
String incomingNumber = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
if(state.equals(TelephonyManager.EXTRA_STATE_RINGING)){
}
}
catch (Exception e){
e.printStackTrace();
}
}
}
Run Code Online (Sandbox Code Playgroud)
来电将被发送到Activity,被叫ReceiverActivity.在ReceiverActivity接收来电,并通过套接字连接发送到服务器.套接字连接在onCreate函数中初始化.我用谷歌搜索并找到服务器方式将数据传递BroadcastReceiver给Activity.常见的方法是通过putExtra函数和调用发送数据startActivity.但是,该方法将onCreate再次调用然后连接套接字,再次绘制UI.因此,在我的情况下它没有帮助.
在我的目标中,如果手机接到来电,它会将来电发送给ReceiverActivity.该ReceiverActivity接收消息并调用发送功能.这是最好的方法吗?谢谢
将数据从a传递BroadcastReceiver到ReceiverActivity我使用的常用方法如下所示
在PhoneStateReceiver类中:
Intent intent_phonenum = …Run Code Online (Sandbox Code Playgroud) 嗨,我想知道如何禁用Google Maps左上角的北对齐罗盘按钮。我链接了一张图片以显示我在说什么。我已经找到了如何禁用其他UI组件的方法,但是关于禁用此按钮一无所获。我正在使用android studio。
谢谢!
android ×10
android-collapsingtoolbarlayout ×1
build-tools ×1
caching ×1
database ×1
datepicker ×1
delete-row ×1
firebase ×1
google-maps ×1
layout ×1
listview ×1
realm ×1
scrollview ×1
sockets ×1