Login and Register Function+Merge+New

ongbodev
ongbo 6 years ago
parent 3374b07c69
commit e81a37dc8a

@ -24,14 +24,22 @@ android {
} }
dependencies { 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' implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0' androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
api 'com.hankcs:hanlp:portable-1.7.2' api 'com.hankcs:hanlp:portable-1.7.2'
implementation 'com.google.android.material:material:1.0.0' implementation 'com.google.android.material:material:1.0.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.1' // implementation 'androidx.appcompat:appcompat:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' // implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation fileTree(dir: 'libs', include: ['*.aar', '*.jar'], exclude: []) // 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:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
<activity android:name=".PersonalityCenterActivity" />
<activity android:name=".LoginActivity" />
<activity android:name=".RegisterActivity" />
<activity android:name=".MainActivity"> <activity android:name=".MainActivity">
<intent-filter> <intent-filter>

@ -1,22 +1,78 @@
package com.example.cmknowledgegraph; 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.appcompat.app.AppCompatActivity;
import androidx.annotation.NonNull;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import android.os.Bundle; import android.view.MenuItem;
import android.util.Log; import android.widget.TextView;
import android.view.View;
import android.widget.Button;
import com.example.PersonalCenter.Login; import java.util.List;
import com.example.PersonalCenter.Register;
public class MainActivity extends AppCompatActivity { public class MainActivity extends AppCompatActivity {
private TextView mTextMessage;
private FragmentTransaction transaction;
private FragmentManager fragmentManager;
private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
= new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override @Override
protected void onCreate(Bundle savedInstanceState) {
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); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); 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"?> <?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:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container" android:id="@+id/container"
@ -26,12 +26,4 @@
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/bottom_nav_menu" /> app:menu="@menu/bottom_nav_menu" />
<Button </androidx.constraintlayout.widget.ConstraintLayout>
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>
Loading…
Cancel
Save