小编H R*_*val的帖子

带有多个倒计时器的Recyclerview会导致闪烁

我想表明我的每个单元格内剩下多少时间RecyclerView......因为我已经为每个单元格使用了倒数计时器.在每一行我开始一个计数器并管理onTick()...所有工作都按预期工作...我有一个计时器勾选每一行,我的单元格也在更新但我的单元格现在闪烁....当它变得疯狂时我滚动.

这是我的适配器......

if (product.getProductType().equalsIgnoreCase("Auction Product")) {
                isAuction=true;
                viewHolder.img_product_type.setImageResource(R.drawable.bid);
                viewHolder.txt_timeleft.setVisibility(View.VISIBLE);
               start_countDown(product.getStart(),product.getStop(),viewHolder.txt_timeleft);
            }
Run Code Online (Sandbox Code Playgroud)

计数器代码如下....

private void start_countDown(String start, String stop, final TextView txt_timeleft) {
        try {
            //Log.e("hetal",start+"....."+stop);
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

            Calendar start_date = Calendar.getInstance();
            start_date.setTime(format.parse(start));

            Calendar end_date = Calendar.getInstance();
            end_date.setTime(format.parse(stop));

            final Calendar today = Calendar.getInstance();
            CountDownTimer timer;

            txt_timeleft.setTextColor(Color.DKGRAY);
            if(today.before(start_date)){
                txt_timeleft.setTextColor(context.getResources().getColor(R.color.red));
                txt_timeleft.setText(context.getString(R.string.auction_not_start));
                Animation anim = new AlphaAnimation(0.0f, 1.0f);
                anim.setDuration(1000); //You can manage the time of the blink with this parameter
                anim.setStartOffset(20);
                anim.setRepeatMode(Animation.REVERSE);
                anim.setRepeatCount(Animation.INFINITE);
                txt_timeleft.startAnimation(anim);
                return;
            } …
Run Code Online (Sandbox Code Playgroud)

android countdowntimer android-recyclerview

8
推荐指数
1
解决办法
7083
查看次数

更改导航视图组项目背景

我想仅更改组项目的背景颜色.我能够更改所有项目或所选项目的颜色,也可以更改分隔符颜色,但我不知道如何更改分隔符标题背景.

这是我的代码

    <?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto">
    <group>
        <item android:id="@+id/main"
              android:title="Main Menu">
         <menu> <group android:checkableBehavior="single">
        <item android:id="@+id/home"
              android:title="Home" />

        <item android:id="@+id/fav"
              android:title="Favourite"/>

        <item android:id="@+id/setting"
              android:title="Settings" />
         </group></menu>
        </item>
        <item android:id="@+id/sub_menu"
              android:title="Second Menu"
            >
            <menu>
                <group android:checkableBehavior="single">
                <item android:id="@+id/more"
                      android:title="more" />
                </group>
            </menu>
        </item>
    </group>
</menu>
Run Code Online (Sandbox Code Playgroud)

在这里我想改变主菜单和第二菜单的颜色.

android android-navigationview

5
推荐指数
0
解决办法
569
查看次数

res图像中的Prolog中不允许使用内容

我已经阅读了其他人的答案,但我无法弄明白......请帮助我.当我厌倦了将我的启动画面图像复制到res文件夹...复制文件后,我收到了这个错误

home/nteam/OrderliteProject/Orderlite/app/src/main/res/xxxhdpi/sp_bg.png
Error:(1, 1) Error: Content is not allowed in prolog.
/home/nteam/OrderliteProject/Orderlite/app/src/main/res/hdpi/sp_bg.png
Error:(1, 1) Error: Content is not allowed in prolog.
/home/nteam/OrderliteProject/Orderlite/app/src/main/res/xxhdpi/sp_bg.png
Error:(1, 1) Error: Content is not allowed in prolog.
/home/nteam/OrderliteProject/Orderlite/app/src/main/res/mdpi/sp_bg.png
Error:(1, 1) Error: Content is not allowed in prolog.
/home/nteam/OrderliteProject/Orderlite/app/src/main/res/ldpi/sp_bg.png
Error:(1, 1) Error: Content is not allowed in prolog.
/home/nteam/OrderliteProject/Orderlite/app/src/main/res/xhdpi/sp_bg.png
Error:(1, 1) Error: Content is not allowed in prolog.
:app:mergeDebugResources FAILED
Run Code Online (Sandbox Code Playgroud)

我也试图删除这些图像,并尝试重新编译它,但我钢铁得到同样的错误.请帮我.

android android-studio

5
推荐指数
1
解决办法
5719
查看次数

表格视图单元格内的 UIButton 更改文本

好吧,我知道这些类型的问题以前由 SO 回答过,但我的问题不大,所以请阅读。

我在 tableview 单元格内使用按钮。单击按钮时,我会显示一个带有操作列表的 AlertViewController。在选择操作时,我的按钮文本和我的自定义模型类属性发生了变化。

单击按钮时按钮文本会发生变化。但我的问题是单元格不存储按钮状态。如果我更改第一个单元格的按钮,然后单击第二个单元格按钮,则所有其他按钮都恢复为默认文本。

请看这个视频

这是我的代码

设置单元格数据

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCellWithIdentifier("dbColumns", forIndexPath: indexPath) as! CustomColumnTableViewCell

        let column = columns[indexPath.row]
        cell.dbColumnName.text = column.name
        cell.dbColumnOrder.titleLabel?.text = column.order
        cell.dbColumnOrder.tag = indexPath.row

        print(columns)
        cell.dbColumnOrder.addTarget(self, action: #selector(ViewController.showAlert(_:)), forControlEvents: UIControlEvents.TouchUpInside)
        return cell
    }
Run Code Online (Sandbox Code Playgroud)

单击按钮时的操作

//MARK:Show Alert
    func showAlert(sender:UIButton){
        let alert = UIAlertController(title: "Column Order", message: "Please select column order", preferredStyle: .ActionSheet)
        let index = sender.tag
        let indexPath = NSIndexPath(forRow: index, inSection: 0)

        alert.addAction(UIAlertAction(title: …
Run Code Online (Sandbox Code Playgroud)

uibutton uitableview ios swift

2
推荐指数
1
解决办法
1641
查看次数

滚动视图内的两列RecyclerView

我想要我的2列RecyclerView,即GridLayoutManager在scrollview中使用.我找到了一种方法,可以从这个链接中将单列recyclelerview放在scrollview中,但我无法弄清楚如何将Grid RecyclerView放在scrollview中.

android scrollview android-recyclerview

0
推荐指数
1
解决办法
5609
查看次数