Как вытащить живой текст из Google Docs как кто -то редактирует и набирает документAndroid

Форум для тех, кто программирует под Android
Ответить Пред. темаСлед. тема
Anonymous
 Как вытащить живой текст из Google Docs как кто -то редактирует и набирает документ

Сообщение Anonymous »

В следующем коде я получаю следующие ошибки:
tablayout : Никакого говорится о том, что
не смог создать одно или несколько классов < /p>
Я искал онлайн, и все подобные проблемы с Edittex Код. < /p>








< /code>
Вот мой основной файл активности < /p>
То, что я попробовал, указано выше < /p>
package com.example.sahir_sood_myruns1

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.viewpager2.widget.ViewPager2
import com.google.android.material.tabs.TabLayout

class MainActivity : AppCompatActivity() {

// Declare variables for TabLayout, ViewPager2, and the adapter
private lateinit var tabLayout: TabLayout
private lateinit var viewPager2: ViewPager2
private lateinit var adapter: FragmentPageAdapter

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main) // Set the content view to your XML layout

// Find the TabLayout and ViewPager2 in the layout by their respective IDs
tabLayout = findViewById(R.id.tabLayout)
viewPager2 = findViewById(R.id.viewPager2)

// Initialize the adapter with the FragmentManager and the lifecycle
adapter = FragmentPageAdapter(supportFragmentManager, lifecycle)

// Add tabs to the TabLayout, each with a title (Start, History, Settings)
tabLayout.addTab(tabLayout.newTab().setText("Start").setContentDescription("Start Tab"))
tabLayout.addTab(tabLayout.newTab().setText("History").setContentDescription("History Tab"))
tabLayout.addTab(tabLayout.newTab().setText("Settings").setContentDescription("Settings Tab"))

// Set the adapter for the ViewPager2 so it knows which fragments to display
viewPager2.adapter = adapter

// Add a listener to handle user interaction with the TabLayout (i.e., when the user clicks on a tab)
tabLayout.addOnTabSelectedListener(object: TabLayout.OnTabSelectedListener {
// This method is called when a tab is selected
override fun onTabSelected(tab: TabLayout.Tab?) {
if (tab != null) {
// When a tab is selected, update the ViewPager2 to show the corresponding fragment
viewPager2.currentItem = tab.position
}
}

override fun onTabUnselected(tab: TabLayout.Tab?) {
// This method is called when a tab is unselected, but nothing happens in this case
}

override fun onTabReselected(tab: TabLayout.Tab?) {
// This method is called when a tab is reselected, but nothing happens in this case
}
})

// Add a callback to handle page changes in the ViewPager2 (i.e., when the user swipes between pages)
viewPager2.registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() {
// This method is called when a new page is selected
override fun onPageSelected(position: Int) {
super.onPageSelected(position)
// When the page is changed, update the TabLayout to highlight the corresponding tab
tabLayout.selectTab(tabLayout.getTabAt(position))
}
})
}
}



Подробнее здесь: https://stackoverflow.com/questions/796 ... a-document
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Android»