Kotlinを使用してAndroidListViewの色とフォントを変更するにはどうすればよいですか?
この例は、Kotlinを使用してAndroidListViewの色とフォントを変更する方法を示しています。
ステップ1 − Android Studioで新しいプロジェクトを作成し、ファイルに移動しますか?新しいプロジェクトを作成し、必要なすべての詳細を入力して新しいプロジェクトを作成します。
ステップ2 −次のコードをres / layout/activity_main.xmlに追加します。
例
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="https://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:fontFamily="sans-serif-condensed" android:textColor="@android:color/holo_orange_dark" android:textSize="24sp" android:textStyle="italic|bold" /> </LinearLayout>
ステップ3 −次のコードをsrc / MainActivity.kt
に追加しますimport android.os.Bundle import android.widget.ArrayAdapter import android.widget.ListView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() { var operatingSystem: Array<String> = arrayOf("Android", "IPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) title = "KotlinApp" val listView: ListView = findViewById(R.id.listView) val adapter = object : ArrayAdapter<String>(this, R.layout.list_item, R.id.textView, operatingSystem) { } listView.adapter = adapter } }
ステップ4 −レイアウトリソースファイル(list_item.xml)を作成し、次のコードを追加します-
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="https://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:fontFamily="sans-serif-condensed" android:textColor="@android:color/holo_orange_dark" android:textSize="24sp" android:textStyle="italic|bold" /> </LinearLayout>
ステップ5 −次のコードをandroidManifest.xmlに追加します
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="https://schemas.android.com/apk/res/android" package="com.example.q11"> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
アプリケーションを実行してみましょう。実際のAndroidモバイルデバイスをコンピューターに接続していると思います。 Android Studioからアプリを実行するには、プロジェクトのアクティビティファイルの1つを開き、[実行]アイコンをクリックします ツールバーから。オプションとしてモバイルデバイスを選択し、デフォルトの画面を表示するモバイルデバイスを確認します
-
Android ListViewの色とフォントを変更するにはどうすればよいですか?
この例は、AndroidListViewの色とフォントを変更する方法を示しています。 ステップ1 − Android Studioで新しいプロジェクトを作成し、[ファイル]⇒[新しいプロジェクト]に移動して、新しいプロジェクトを作成するために必要なすべての詳細を入力します。 ステップ2 −次のコードをres / layout/activity_main.xmlに追加します。 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http:
-
Accessでフォントの面、サイズ、色を変更する方法
この投稿では、 Microsoft Accessでフォントの面、サイズ、色を変更する方法を紹介します。 。 Microsoft Officeでは、フォントは書体であり、その面、サイズ、色を変更できます。ドキュメントやデータベースに入力するときに大きな役割を果たします。 Microsoft Officeには、好みに合わせて変更できるフォントスタイルが多数含まれています。 Microsoft Officeユーザーは、Officeアプリケーションに新しいフォントを追加することもできます。 Accessでフォントの面、サイズ、色を変更する方法 MicrosoftAccessでフォント面を変更す