Git Product home page Git Product logo

Comments (8)

KingJA avatar KingJA commented on September 23, 2024

@liguangze 请问你使用的是哪个版本?动态添加View出异常能不能详细描述下?

from loadsir.

liguangze avatar liguangze commented on September 23, 2024

1.30,我没有使用这种方式,因为不想改变我的基类,且在基类中动态添加,还有不想改最外层布局,没有出现异常,就是感觉会容易出现,有没有什么比较简单的实现方式

from loadsir.

KingJA avatar KingJA commented on September 23, 2024

@liguangze 不知道你有没参考过v1.3.2 Demo中的KeepTitleActivity,把Title的设置抽取到基类BaseTitleActivity中,由子类去实现。

from loadsir.

liguangze avatar liguangze commented on September 23, 2024

我看到了,我发现一个留头的好实现方式了,
loadService = LoadSir.getDefault().register(this, new Callback.OnReloadListener() {
@OverRide
public void onReload(View v) {
//网络错误后,点击重新加载逻辑
}
});

里面的参数第一个参数传的是this,我发现不传this,布局的父布局,这样就不会把头隐藏了
这是我的xml

<include layout="@layout/item_toolbar_layout" />

<com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout

    android:id="@+id/swipeRefreshLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<android.support.v7.widget.RecyclerView
    android:id="@+id/hot_book_list"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollbars="none">
</android.support.v7.widget.RecyclerView>
</com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout>

只要是把swipeRefreshLayout这个id传过去,不传this,这样可以很好的保留activity的title,比抽取基类要简单的多,

from loadsir.

KingJA avatar KingJA commented on September 23, 2024

@liguangze 这就是类似View的注册方式啊,好吧,你成功地带我饶了一圈。

from loadsir.

liguangze avatar liguangze commented on September 23, 2024

不是的,我遇到的问题是留title,不是注册的方式,但是我稍微给了下你的源码,已经解决了,activity中不用再基类中就可以显示title了

from loadsir.

NicodeLee avatar NicodeLee commented on September 23, 2024

@liguangze 这样还是要多写代码。
@KingJA K 看了demo BaseTitleActivity.java,这样虽然好,不过如果是后期要加入需要改动的也不少。
比如内容view要统一加id fl_content ,子act布局去掉标题布局,改统一在基类加,还要处理有标题跟无标题的情况。

from loadsir.

KingJA avatar KingJA commented on September 23, 2024

@liguangze fl_content 是抽象到父类的内容布局,子类只要去实现自己的布局即可。关于标题栏的所有设置都可以抽取到父类,BaseTitleActivity适用于需要标题栏的Activity,如果你不需要标题栏或者自定义复杂标题栏可以直接实现或继承别的父类。

from loadsir.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.