Login and Register Function+Merge+New

ongbodev
ongbo 6 years ago
parent 3374b07c69
commit e81a37dc8a

@ -24,14 +24,22 @@ android {
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
api 'com.hankcs:hanlp:portable-1.7.2'
implementation 'com.google.android.material:material:1.0.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation fileTree(dir: 'libs', include: ['*.aar', '*.jar'], exclude: [])
// implementation 'androidx.appcompat:appcompat:1.1.0'
// implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
// testImplementation 'junit:junit:4.12'
// androidTestImplementation 'androidx.test.ext:junit:1.1.0'
// androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
// api 'com.hankcs:hanlp:portable-1.7.2'
// implementation 'com.google.android.material:material:1.0.0'
// androidTestImplementation 'androidx.test.ext:junit:1.1.1'
// androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
// implementation fileTree(dir: 'libs', include: ['*.aar', '*.jar'], exclude: [])
}

@ -15,7 +15,9 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".PersonalityCenterActivity" />
<activity android:name=".LoginActivity" />
<activity android:name=".RegisterActivity" />
<activity android:name=".MainActivity">
<intent-filter>

@ -1,22 +1,78 @@
package com.example.cmknowledgegraph;
import android.os.Bundle;
import com.example.cmknowledgegraph.MainContent;
import com.example.cmknowledgegraph.R;
import com.example.cmknowledgegraph.SearchContent;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.hankcs.hanlp.HanLP;
import androidx.appcompat.app.AppCompatActivity;
import androidx.annotation.NonNull;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.view.MenuItem;
import android.widget.TextView;
import com.example.PersonalCenter.Login;
import com.example.PersonalCenter.Register;
import java.util.List;
public class MainActivity extends AppCompatActivity {
private TextView mTextMessage;
private FragmentTransaction transaction;
private FragmentManager fragmentManager;
private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
= new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
protected void onCreate(Bundle savedInstanceState) {
@Override
public boolean onNavigationItemSelected(MenuItem item) {
fragmentManager = getSupportFragmentManager(); //使用fragmentmanager和transaction来实现切换效果
transaction = fragmentManager.beginTransaction();
switch (item.getItemId()) {
case R.id.home:
transaction.replace(R.id.content,new MainContent()); //对应的java class
transaction.commit(); //一定不要忘记commit否则不会显示
return true;
case R.id.search:
transaction.replace(R.id.content,new SearchContent()); //对应的java class
transaction.commit(); //一定不要忘记commit否则不会显示
return true;
case R.id.chat:
return true;
case R.id.person:
transaction.replace(R.id.content,new PersonContent()); //对应的java class
transaction.commit(); //一定不要忘记commit否则不会显示
return true;
}
return false;
}
};
// 设置默认进来是tab 显示的页面
private void setDefaultFragment(){
fragmentManager = getSupportFragmentManager();
transaction = fragmentManager.beginTransaction();
transaction.replace(R.id.content,new MainContent());
transaction.commit();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
System.out.println("haha");
setDefaultFragment(); //上面写的那个函数
BottomNavigationView navView = findViewById(R.id.nav_view);
mTextMessage = findViewById(R.id.message);
navView.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
//HanLP测试
String content = "发烧感冒";
List<String> keywordList = HanLP.extractKeyword(content, 5);
System.out.println(keywordList);
}
}
}
}

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout 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:id="@+id/container"
@ -26,12 +26,4 @@
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/bottom_nav_menu" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
tools:layout_editor_absoluteX="189dp"
tools:layout_editor_absoluteY="272dp" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Loading…
Cancel
Save