Android Open Source - OpenHSK Character View Activity






From Project

Back to project page OpenHSK.

License

The source code is released under:

This work is licensed under a Creative Commons Attribution 3.0 Unported License. Original author of word lists: http://lingomi.com/ Original author of definitions: http://cc-cedict.org Original autho...

If you think the Android project OpenHSK listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package edu.openhsk;
//from w w  w  .  j a v a  2s  . c  o m
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
import android.widget.Toast;
import edu.openhsk.models.Hanzi;
import edu.openhsk.repository.DatabaseHelper;

public class CharacterViewActivity extends Activity {
  private static final String LOG_TAG = CharacterViewActivity.class.getSimpleName();

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.singlechar);
    setTitle(getString(R.string.random_word));
    
    Intent intent = getIntent();
    int id = intent.getIntExtra("edu.openhsk.randomindex", 1);
        
    DatabaseHelper dbh = new DatabaseHelper(this);
    Hanzi charData = dbh.getWordById(id);
    if (charData != null) {
      TextView tv = (TextView) findViewById(R.id.charView);
      tv.setText(charData.getWord());
      
      TextView tv2 = (TextView) findViewById(R.id.pinyinView);
      tv2.setText(charData.getPinyin());
      
      TextView tv1 = (TextView) findViewById(R.id.descrView);
      tv1.setText(charData.getDefinition());
    } else {
      String errorMsg = "No hanzi found for id: " + id;
      Log.e(LOG_TAG, errorMsg);
      Toast.makeText(this, errorMsg, Toast.LENGTH_LONG).show();
    }
  }

}




Java Source Code List

edu.openhsk.CharacterListActivity.java
edu.openhsk.CharacterViewActivity.java
edu.openhsk.CreateWordActivity.java
edu.openhsk.CreateWordListActivity.java
edu.openhsk.ExamActivity.java
edu.openhsk.ExamResultActivity.java
edu.openhsk.MainActivity.java
edu.openhsk.QuizActivity.java
edu.openhsk.WordListSelectionActivity.java
edu.openhsk.adapters.WordListViewBinder.java
edu.openhsk.adapters.WordViewBinder.java
edu.openhsk.models.ExamResult.java
edu.openhsk.models.Hanzi.java
edu.openhsk.models.QuizHanzi.java
edu.openhsk.models.WordList.java
edu.openhsk.repository.DatabaseHelper.java
edu.openhsk.repository.DatabaseMetadata.java
edu.openhsk.repository.HanziRepository.java
edu.openhsk.repository.HelpfulCursor.java
edu.openhsk.repository.QuizRepository.java
edu.openhsk.repository.SimpleCursorLoader.java
edu.openhsk.repository.WordListRepository.java
edu.openhsk.service.QuizService.java
edu.openhsk.utils.AsyncSoundPlayer.java
edu.openhsk.utils.CSVExporter.java
edu.openhsk.utils.CSVParser.java
edu.openhsk.utils.PinyinReplacer.java
edu.openhsk.utils.SoundManager.java
edu.openhsk.views.BarGraph.java
edu.openhsk.views.Bar.java
edu.openhsk.views.ExamResultPieChart.java