我有一个自定义列表视图,当我单击删除按钮删除当前行时,我有2个文本视图和2个按钮(播放和删除按钮).
我的适配器类
import java.util.ArrayList;
import android.content.Context;
import android.graphics.Color;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.TextView;
public class SunetePreferateAdaptor extends BaseAdapter {
class ob {
String titlu, descriere;
public ob(String titlu, String descriere) {
this.titlu = titlu;
this.descriere = descriere;
}
}
ArrayList<ob> lista;
Context context;
public SunetePreferateAdaptor(Context context) {
this.context = context;
lista = new ArrayList<ob>();
for (int i = 1; i <= 20; i++) {
lista.add(new ob("text", "text2"));
}
} …Run Code Online (Sandbox Code Playgroud) 我有一个精灵,我知道位置和背后的矩形.我想获得精灵背后的位置,我知道偏移量.
我的意思是
Point p=new Point(sprite.getX()-offset,sprite.getY()-sprite.getHeight()/2);
Run Code Online (Sandbox Code Playgroud)
如果我围绕它的中心原点旋转我的精灵,我想获得该点的新位置.
一个可以更好地解释的图像:

我有一个片段对话框的问题,如果手机处于纵向模式,一切正常,对话框几乎全屏,但是当我旋转手机时,在景观中两侧有一些大的间隙..可能解决这个问题?

我叫这个
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
Run Code Online (Sandbox Code Playgroud)
摆脱DIalogFragment标题.我正在使用线性布局.
我试图看到每当我从我的API获得代码401的响应.但是当我这样做时,我得到一个IOException
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
Response response = chain.proceed(request);
if (response.code() == 401) {
mLoginToken.delete();
Toast.makeText(mApplication.getApplicationContext(), R.string.session_error, Toast.LENGTH_SHORT).show();
Intent intent = new Intent(mApplication.getApplicationContext(), LoginActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
mApplication.startActivity(intent);
}
return response;
}
Run Code Online (Sandbox Code Playgroud)
我将得到错误java.io.IOException:连接上的意外结束流{proxy = DIRECT @ hostAddress = cipherSuite = none protocol = http/1.1}(recycle count = 0)
在线
Response response = chain.proceed(request);
Run Code Online (Sandbox Code Playgroud)
我应该如何获得401(未授权代码)的响应才能处理这个问题?
设想:
从一开始就在启用互联网的情况下重新启动应用程序将使一切正常,除非我再次关闭它并失败请求,从那时起它会给我同样的错误。我在 Java 上从来没有遇到过这个问题,只是在 Kotlin 上。
private val interceptor: Interceptor =
object : Interceptor {
override fun intercept(chain: Interceptor.Chain): Response {
var builder = chain.request().newBuilder()
Prefs.token?.let { token ->
builder = builder.addHeader("Authorization", "Bearer $token")
}
return chain.proceed(builder.build())
}
}
private val httpLoggingInterceptor: HttpLoggingInterceptor by lazy {
val interceptor = HttpLoggingInterceptor()
interceptor.level =
if (BuildConfig.DEBUG) HttpLoggingInterceptor.Level.BODY else HttpLoggingInterceptor.Level.NONE
interceptor
}
private val httpClient: OkHttpClient by lazy {
OkHttpClient.Builder()
.addInterceptor(httpLoggingInterceptor)
.addInterceptor(interceptor)
.build() …Run Code Online (Sandbox Code Playgroud) 我目前有一个片段标签主机,由本教程制作 http://maxalley.wordpress.com/2013/05/18/android-creating-a-tab-layout-with-fragmenttabhost-and-fragments/
唯一的区别是我在片段中使用它.所以我有一个带有标签的片段,每个标签都有另一个片段..
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
片段类
public class AddServiceFragment extends Fragment {
public AddServiceFragment() {
// Required empty public constructor
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_add_service, container, false);
FragmentTabHost mTabHost = (FragmentTabHost) view.findViewById(android.R.id.tabhost);
mTabHost.setup(getActivity(), getChildFragmentManager(), android.R.id.tabcontent);
String[] tabs = new String[]{"text1", "text2"};
mTabHost.addTab(
mTabHost.newTabSpec("tab1").setIndicator(tabs[0], null),
MedicalHistoryFragment.class, null);
mTabHost.addTab(
mTabHost.newTabSpec("tab2").setIndicator(tabs[1], …Run Code Online (Sandbox Code Playgroud) 是否可以为EditText更改TextInputLayout错误文本字体?
我只能通过app:errorTextAppearance更改颜色或文本大小。
我想将long中的日期转换为ISO_8601字符串.
例如:
2014-11-02T20:22:35.059823+01:00
Run Code Online (Sandbox Code Playgroud)
我的代码
long timeInLong=System.currentTimeMillis();
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mmZ");
String fmm = df.format(new java.util.Date(timeInLong));
System.out.println(fmm);
Run Code Online (Sandbox Code Playgroud)
这将显示在我的控制台中
2014-11-04T15:57+0200
Run Code Online (Sandbox Code Playgroud)
我想我想得到它
2014-11-04T15:57+02:00
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?(没有字符串函数)
TL,DR:我如何强制再循环视图再次调用onBindViewHolder方法,至少对于可见项?
调用notifyDataSetChanged()会使列表滞后几毫秒,有没有更好的方法?谢谢.
我有一个带有ImageView的布局.当为imageview调用bind时,我向服务器发送请求以获取图像.加载图像时,我将位图保存在ViewHolder,T变量中.在bind方法中,我检查variable.getBitmap()是否为null,如果是,我将设置imageview.现在,如果我滚动列表,将加载图像,但如果没有,则图像视图仍为空白,因为未再次调用onBindViewHolder.
谢谢.
这就是我的桌子。
这样一首歌可以获得更多选票。我想获取所有歌曲,按其获得的票数排序。我怎样才能做到这一点?
示例:歌曲表将是
1,"Master Of Puppets"
2,"Don't Cry"
3,"Baby"
4,"Song name"
5,"I want to break free"
Run Code Online (Sandbox Code Playgroud)
和投票:
1,5
2,5
3,5
4,2
5,2
6,1
Run Code Online (Sandbox Code Playgroud)
我想查询歌曲表以获得投票最多的歌曲,应该按此顺序
5,"I want to break free"
2,"Don't cry"
1,"Master Of Puppets"
3,"Baby"
4,"Song name"
Run Code Online (Sandbox Code Playgroud)
有没有办法仅通过一个查询来执行此操作?我知道我可以查询所有歌曲,然后查询每首歌曲的票表,其中songId是当前歌曲的ID,但是我可以只执行一次查询吗?