直播平台怎么搭建,简单的软件更新公告模块

直播平台怎么搭建,简单的软件更新公告模块

第一步:建一个实体类News

 

public class News {
    private String Title;//标题
    private String Content;//内容
    public News(String Title, String Content){
        this.Title = Title;
        this.Content = Content;
    }
    public String getTitle() {
        return Title;
    }
    public String getContent() {
        return Content;
    }
}

 

第二步:新建一个活动NewsContent

 

public class NewsContent extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_news_content);
        String newsTitle = getIntent().getStringExtra("news_title");
        String newsContent = getIntent().getStringExtra("news_content");
        NewsContentFragment newsContentFragment = (NewsContentFragment)
                getSupportFragmentManager().findFragmentById(R.id.news_content_fragment);
        newsContentFragment.Refresh(newsTitle,newsContent);
    }
    public static void ActionStart(Context context, String newsTitle, String newsContent ){
        Intent intent = new Intent(context,NewsContent.class);
        intent.putExtra("news_title",newsTitle);
        intent.putExtra("news_content",newsContent);
        context.startActivity(intent);
    }
}
 

 

布局文件

 

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"   
    android:layout_width="match_parent"    
    android:layout_height="match_parent">   
    <fragment       
        android:id="@+id/news_content_fragment"
        android:name="com.example.newsinterface.NewsContentFragment"
        android:layout_width="match_parent"      
        android:layout_height="match_parent"/>       
</LinearLayout>
<font size =4  color = "#ff0000">第三步:建立一个子布局content_show,用做新闻内容布局</font>

 

代码如下:

 

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <LinearLayout
        android:id="@+id/liner_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:visibility="invisible">
        <TextView
            android:id="@+id/NewsTitle"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:padding="10dp"
            android:textSize="20sp"/>
        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="#000"/>
        <TextView
            android:id="@+id/NewsContent"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:padding="15dp"
            android:textSize="18sp"/>
    </LinearLayout>
    <View
        android:layout_width="1dp"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:background="#000"/>
        
</RelativeLayout>

 

 以上就是 直播平台怎么搭建,简单的软件更新公告模块,更多内容欢迎关注之后的文章

 

posted @ 2022-11-14 14:16  云豹科技-苏凌霄  阅读(270)  评论(0)    收藏  举报