今天做了什么:

手机上的政策软件通过webview运行html代码

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragment.typeFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp"
android:layout_marginTop="20dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="@+id/ed_select"
android:layout_width="370dp"
android:layout_height="wrap_content"
android:background="@drawable/ed_backgroud"
/>
<ImageView
android:id="@+id/iv_select"
android:layout_width="25dp"
android:layout_height="25dp"
android:scaleType="centerCrop"
android:src="@drawable/baseline_youtube_searched_for_24"/>
</LinearLayout>
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>

</FrameLayout>
package com.hui.policy;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentContainerView;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hui.policy.fragment.main_fragment;
import com.hui.policy.fragment.typeFragment;


public class MainActivity extends AppCompatActivity implements View.OnClickListener {
Toolbar toolbar;
LinearLayout ll_home,ll_community,ll_self;
ImageView iv_home,iv_community,iv_self;
TextView tv_home,tv_community,tv_self;
FragmentContainerView fcv;
FragmentManager fragmentManager;
FragmentTransaction fragmentTransaction;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
toolbar =(Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

init();
initevent();
getintent();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater menuInflater = getMenuInflater();
menuInflater.inflate(R.menu.menu,menu);
return super.onCreateOptionsMenu(menu);
}
public void init(){
ll_home=findViewById(R.id.ll_home);
ll_community=findViewById(R.id.ll_community);
ll_self=findViewById(R.id.ll_self);
ll_home.setOnClickListener(this);
ll_community.setOnClickListener(this);
ll_self.setOnClickListener(this);
iv_community=findViewById(R.id.iv_community);
iv_home=findViewById(R.id.iv_home);
iv_self=findViewById(R.id.iv_self);
tv_home=findViewById(R.id.tv_home);
tv_community=findViewById(R.id.tv_community);
tv_self=findViewById(R.id.tv_self);
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
int itemid= item.getItemId();
switch(itemid){
case R.id.menu_main:
// Intent intent=new Intent(this, baiduapi.class);
// startActivity(intent);
case R.id.menu_add_comm:
// Intent intent1=new Intent(this, addcontent.class);
// startActivity(intent1);
}
return super.onOptionsItemSelected(item);
}
public void getintent(){
Intent intent=getIntent();
String text=intent.getStringExtra("text");
//TextView textView=findViewById(R.id.text3);
WebView webView=findViewById(R.id.web);
webView.loadData(text,"text/html; charset=UTF-8", null);
//textView.setText(text);
}
public void initevent(){
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.fcv, main_fragment.newInstance("","")).commit();
iv_home.setSelected(true);
tv_home.setTextColor(ContextCompat.getColor(this,R.color.green_700));
}
public void initevent1(){
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.fcv, typeFragment.newInstance("","")).commit();
}

@Override
public void onClick(View v) {
setselector();
switch(v.getId()){
case R.id.ll_home:
toolbar.setTitle("主界面");
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.fcv, main_fragment.newInstance("","")).commit();
iv_home.setSelected(true);
tv_home.setTextColor(ContextCompat.getColor(this,R.color.green_700));
break;
case R.id.ll_community:
toolbar.setTitle("分类");
FragmentManager fragmentManager1 = getSupportFragmentManager();
FragmentTransaction fragmentTransaction1 = fragmentManager1.beginTransaction();
fragmentTransaction1.replace(R.id.fcv, typeFragment.newInstance("","")).commit();
iv_community.setSelected(true);
tv_community.setTextColor(ContextCompat.getColor(this,R.color.green_700));
break;
case R.id.ll_self:
toolbar.setTitle("个人信息");
break;
}

}
public void setselector(){

iv_home.setSelected(false);
iv_community.setSelected(false);
iv_self.setSelected(false);
tv_home.setTextColor(ContextCompat.getColor(this, R.color.gray));
tv_community.setTextColor(ContextCompat.getColor(this, R.color.gray));
tv_self.setTextColor(ContextCompat.getColor(this, R.color.gray));
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent"
tools:context=".MainActivity">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/purple_500"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
<androidx.fragment.app.FragmentContainerView
android:id="@+id/fcv"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<WebView
android:id="@+id/web"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="3dp"
android:background="@color/gray"/>
<include layout="@layout/bottom_btn_nav"/>
</LinearLayout>

遇到了什么困难:

 

明天准备做什么:

开始复习

代码量 80

时间 1小时